spacekit.skopes.jwst.cal.predict

Program (PID) of exposures comes into pipeline 1. create list of L1B exposures 2. scrape pix offset vals from scihdrs + any additional metadata 3. determine potential L3 products based on obs, filters, detectors, etc 4. calculate sky separation / reference pixel offset statistics 5. preprocessing: create dataframe of all input values, encode categoricals 6. load model 7. run inference

class spacekit.skopes.jwst.cal.predict.JwstCalPredict(input_path=None, pid=None, obs=None, model_path=None, models={}, tx_file=None, norm=1, norm_cols=['offset', 'max_offset', 'mean_offset', 'sigma_offset', 'err_offset', 'sigma1_mean'], sfx='uncal.fits', expmodes=['IMAGE', 'SPEC'], **log_kws)[source]

Generate predicted memory footprint of Level 3 products using metadata from uncalibrated (Level 1) exposures).

Initializes JwstCalPredict class object. This class can be used to estimate the memory footprint of Level 3 products based on metadata scraped from uncalibrated (Level 1) exposures.

Parameters:
  • input_path (str or Path, optional) – path to input exposure fits files, by default None

  • pid (int, optional) – restrict to exposures matching a specific program ID e.g. 1018, by default None

  • obs (str or int, optional) – restrict to exposures matching a specific observation number (requires pid), by default None

  • model_path (str or Path, optional) – path to saved model directory, by default None

  • models (dict, optional) – dictionary of spacekit.builder.architect.Builder type objects, by default {}

  • tx_file (str or Path, optional) – path to transformer metadata json file, by default None

  • norm (int, optional) – apply normalization and scaling (bool), by default 1

  • norm_cols (list, optional) – index of input columns on which to apply normalization, by default [ “offset”, “max_offset”, “mean_offset”, “sigma_offset”, “err_offset”, “sigma1_mean”]

  • sfx (str, optional) – restrict to exposures matching a specifc filename suffix, by default “uncal.fits”

  • expmodes (list, optional) – specifies which exposure modes to turn on for inference, by default [“IMAGE”, “SPEC”]

classifier(model, data)[source]

Returns class prediction

initialize_models()[source]

Initializes pre-trained models used for inference. Once loaded initially, the models are stored in the global variable JWST_CAL_MODELS to avoid unnecessary reloads over multiple iterations of object instantiation.

load_models(models={})[source]

_summary_

Parameters:

models (dict, optional) – Builder objects with pre-loaded functional models, by default {}

normalize_inputs(inputs, order='IMAGE')[source]

Applies normalization and scaling to continuous data type feature inputs.

Parameters:
  • inputs (pandas.DataFrame) – _description_

  • order (str, optional) – inference exposure mode matching L3 data group, by default “IMAGE”

Returns:

array of input features preprocessed and normalized for ML inference

Return type:

np.array

preprocess()[source]

Runs necessary preprocessing steps on input exposure data prior to inference.

regressor(model, data)[source]

_summary_

Parameters:
  • model (tf.keras.model) – keras functional model

  • data (numpy.array or tf.tensors) – input data on which to run inference

Returns:

Returns Regression model prediction

Return type:

numpy.array

run_image_inference()[source]

Run inference for L3 Image exposure datasets

run_inference()[source]

Main calling function to preprocess input exposures and generate estimated memory footprints.

run_spec_inference()[source]

Run inference for L3 Spectroscopy exposure datasets

verify_input_path()[source]

Verifies input path exists and checks if file or directory. If input_path is a directory, check/set self.pid value If self.obs is not None, validate format (1-3 digits) and append to self.pid If input_path is a file, any files matching first 9 chars and suffix (typically detector, e.g. “nrcb4_uncal.fits”) found in the same directory will be included automatically (assumes standard naming convention of JWST input exposures). - self.input_path is reset to top/parent directory - self.pid is set to the first 9 characters NB these variables are passed through to the Scrubber and Scraper classes to handle the actual searching on local disk for input files.

spacekit.skopes.jwst.cal.predict.load_pretrained_model(**builder_kwargs)[source]

_summary_

Returns:

_description_

Return type:

_type_

spacekit.skopes.jwst.cal.predict.predict_handler(input_path, **kwargs)[source]

handles local invocations