jwst_rogue_path_tool¶
program_data_parser.py¶
This module contains all of the routines for parsing a JWST APT JSON output files
Use¶
Routines in this module can be imported as follows:
>>> from jwst_rogue_path_tool.program_data_parser import aptJsonFile >>> filename = "/path/to/apt_json_file.json" >>> json = aptJsonFile(filename)
- class jwst_rogue_path_tool.program_data_parser.aptJsonFile(json_file)¶
Read and parse JSON file generated from APT
- build_dataframe(tablename, show_table=False)¶
Create pandas dataframe from parsed APT JSON file
Parameters¶
- tablenamestr
Name of table to generate pandas dataframe from.
- show_tablebool
Show table in web browser.
- read_json_file()¶
Read JSON file exported by APT
constants.py¶
Constants used in JWST Rogue Path Tool
Authors¶
Mario Gennaro
Mees Fix
Use¶
Constants in this module can be imported as follows:
>>> from jwst_rogue_path_tool.constants import ( CATALOG_BANDPASS, NIRCAM_ZEROPOINTS, SUSCEPTIBILITY_REGION_FULL, SUSCEPTIBILITY_REGION_SMALL, ZEROPOINT, )
detect_claws.py¶
This module contains objects that perform the data organizing and analysis routines for detecting “Claw” anomalies with NIRCam.
The AptProgram class accepts an APT JSON file that organizes data with observations, visits, exposures and parses them into python objects (mainly pandas dataframes).
These data are then used to calculate whether exposures and observations are susceptible to claw anomalies. We display these data in figures at the exposure and observaiton level.
Authors¶
Mario Gennaro
Mees Fix
- class jwst_rogue_path_tool.detect_claws.aptProgram(jsonfile, angular_step=1.0, usr_defined_obs=None, usr_defined_angles=None, bkg_params=[{'function': <function min>, 'threshold': 0.1}, {'function': <function mean>, 'threshold': 0.2}])¶
Class that handles the APT-program-level information. aptProgram takes the JSON file input and uses the “observations” and “exposureFrame” objects to organize data into python objects that can be used for various analyses.
- get_target_information()¶
Obtain RA and Dec of target from APT JSON file
- class groupby(iterable, key=None)¶
make an iterator that returns consecutive keys and groups from the iterable
- iterable
Elements to divide into groups according to the key function.
- key
A function for computing the group category for each element. If the key function is not specified or is None, the element itself is used for grouping.
- make_background_report(observation, output_directory)¶
Write reports for background restricted position angles (PA’s). This will create a report for the module(s) in the observation provided, this means that the resulting PA’s will be PA’s that are flagged across all filters in the observaion for that module.
- observationdict
Observation out of observations.data attribute
- output_directorystr
Output directory path
- make_report(observation, output_directory)¶
Display of write “observation level” report given an observation in a program.
Parameters¶
- observationdict
Observation out of observations.data attribute
- output_directorystr
Output directory path
- plot_exposures(observation, output_directory=None)¶
Create plot for individual exposures for a given observation. Plot will contain targets defined in a specific inner and outer radius defined by user. Check jwst_rogue_path_tool.plotting.create_exposure_plots for more information.
Parameters¶
- observation_idint
Observation id number to generate figures from.
- plot_observation(observation, output_directory=None)¶
Create plot at the observation level. The “observation level” is defined as all of the valid angles from each exposure combined. Plot will contain targets defined in a specific inner and outer radius defined by user. Check jwst_rogue_path_tool.plotting.create_observation_plot for more information.
Parameters¶
- observation_idint
Observation id number to generate figures from.
- plot_v3pa_vs_flux(observation, output_directory=None)¶
Create plot of position angle vs flux. This plot will only work if users use the angular_step keyword calculate the flux for all 360 degrees of attitude.
- run()¶
Convenience method to build AptProgram
- class jwst_rogue_path_tool.detect_claws.exposureFrames(observation, attitudes, angular_step=None)¶
Class the organizes data from a single observation (made of exposures) into exposure frames. An exposure frame is a group of exposures associated with a value in the NRC order specification table. Exposures with the same order number are a part of the same exposure frame. This object contains
- V2V3_at_one_attitude(ra_degrees, dec_degrees, v3pa, verbose=False)¶
Compute V2,V3 locations of stars at a given attitude
Parameters¶
- ra_degrees, dec_degrees: lists of floats
stellar coordinates in decimal degrees
Returns¶
- v2_degrees: float
V2 position in degrees
- v3_degrees: float
V2 position in degrees
- assign_catalog(catalog_name='2MASS')¶
Obtain magnitude selected catalog as pandas dataframe.
Parameters¶
- catalog_namestr
Survey name of catalog with star positions and magnitudes [options: 2MASS, SIMBAD]
- build_exposure_frames_data()¶
Use exposure table to separate data into exposure frame specific pandas dataframes. Resetting the index to combinations of exposure and order number will separate the exposures into exposures associate with a specific dither pointing. These tables contain exposures that all share the same RA and Dec.
- calculate_attitude(v3pa)¶
Calculate attitude matrix given V3 position angle.
Parameters¶
- v3pafloat
V3 position angle
- check_in_susceptibility_region()¶
Method to check if stars from catalog are located in susceptibility region per angle of attitude. Angles are 0.0 –> 360.0 degrees in steps of self.angular_step. This method creates a large dictionary that contains contain keys “targets_in” and “targets_loc” for each angle of attitude.
For a given angle of attitude, if targets from the catalog fall in the susceptibility region, “targets_in” will be True and “targets_loc” are the indicies of these stars in the catalog.
When an exposure frame uses both modules, “targets_in” and “targets_loc” are two-dimensional.
A B A B A B
“targets_in” : [True, True] or [False, True] … [False, False]
- get_susceptibility_region(exposure)¶
Based on the module of an exposure frame, create a SuceptibilityRegion instance.
Parameters¶
- exposurepandas.core.series.Series
A row from an exposure frame table
- get_total_exposure_duration()¶
- get_visibility_windows()¶
Method to calculate when a target has entered/exited a susceptibility region. This is done at the exposure and observation levels.
- class jwst_rogue_path_tool.detect_claws.observations(apt_json, usr_defined_obs=None)¶
Class the organizes metadata from APT JSON file into python object. This object is organized by observation number and contains metadata associated with it.
- drop_unsupported_observations()¶
Convenience method to drop unsupported observation types. This method checks all observations including parallels. All metadata is kept and new class attribute self.supported_observations which is created to avoid confusion when processing. self.supported_observations are the only observation from a program that are analyzed by jwst_rogue_path_tool.
- class jwst_rogue_path_tool.detect_claws.susceptibilityRegion(module, small=False, smooth=False)¶
Class that describes the JWST NRC susceptibility regions. Creates region and calculates intensities based on magnitude and location of target that falls in susceptibility region.
Parameters¶
- modulestr
Name of JWST NRC module (“A or “B”)
- smallbool
Create smaller susceptibility region (default: False)
- smoothbool
Smooth data with Gaussian Filter (default: False)
- calculate_centroid()¶
Calculate the centroid of a susceptibility region polygons.
- get_intensity(V2, V3)¶
Calculate the intensity of claw caused by star falling in susceptibility region.
- get_intensity_map()¶
Open intensity map reference file
- get_path()¶
Calculate rogue path for plotting.
fixed_angle.py¶
This module contains the FixedAngle class which performs the analysis for JWST Rogue Path Tool.
This routine accepts an observation from the aptProgram class
Authors¶
Mario Gennaro
Mees Fix
- class jwst_rogue_path_tool.fixed_angle.fixedAngle(observation, angle)¶
Analysis for a single fixed V3 position angle. For a specific observation and V3PA the magnitudes/fluxes of stars in and around the susceptibility region are calculated.
Parameters¶
- observationdictionary
Observation entry from aptProgram class
- anglefloat
V3 position angle
- calculate_absolute_magnitude()¶
Calculate the absolute magnitude of the intensities averaged over exposures for the specific V3 position angle.
- get_empirical_zero_points(module, pupil, filter)¶
Get NRC emperical zero point points for pupil/filter combination for module A or B.
Parameters¶
- modulestr
NRC module name (“A” or “B”)
- pupilstr
NRC pupil name
- filterstr
NRC filter name
- get_ground_band(pupil, filter, catalog='2MASS')¶
Get band name from catalog corresponding to JWST NRC pupil/filter combination
Parameters¶
- pupilstr
NRC pupil name
- filterstr
NRC filter name
- catalogstr
Name of source catalog (default: “2MASS”)
- get_total_counts()¶
Calculate the total number of counts based on the calculated magnitudes and exposure durations.
- get_total_magnitudes()¶
Calculate the total (summed) magnitudes for each band in catalog.
- plot_regions()¶
Convenience method for plotting susceptibility region for a single angle in V2/V3 space with maginitude intensity.
plotting.py¶
This module contains all of the plotting functions for the JWST Rogue Path Tool. Plotting output include:
Valid angles at the exposure level
Valid angles at the observation level
Susceptibility region footprint w source intensities.
V3 position angles vs flux at the observation level.
Authors¶
Mario Gennaro
Mees Fix
- jwst_rogue_path_tool.plotting.create_exposure_plots(observation, ra, dec, output_directory=None, **kwargs)¶
Generate exposure level plots
Parameters¶
- rafloat
Right Ascension in degrees
- decfloat
Declination in degrees
- **kwargdict
Arbitrary keyword arguments
- jwst_rogue_path_tool.plotting.create_observation_plot(observation, ra, dec, output_directory=None, **kwargs)¶
Plot that describe all valid angles at the observation level. The observation level plot is a single plot of all valid angles from a set of exposures.
Parameters¶
- rafloat
Right Ascension in degrees
- decfloat
Declination in degrees
- **kwargdict
Arbitrary keyword arguments
- jwst_rogue_path_tool.plotting.create_v3pa_vs_flux_plot(observation, output_directory=None, fontsize=15)¶
Create plot of V3 position angles and flux for a single observation.
Parameters¶
- observationdictionary
Dictionary of data associated with a single observation.
- output_dictionarystr
Directory to save figure to
- fontsizeint
Fontsize for plot
- jwst_rogue_path_tool.plotting.get_susceptibility_region_patch(exposure_frames, exposure_id)¶
Obtain data for susceptibility region and generate plottable patch.
Parameters¶
- exposure_framesjwst_rogue_path_tool.detect_claws.ExposureFrames
ExposureFrame object associated with observation.
- jwst_rogue_path_tool.plotting.locate_targets_in_annulus(catalog, ra, dec, inner_radius, outer_radius)¶
Calculate the targets from a catalog that fall within inner and outer radii.
Parameters¶
- catalogpandas.core.frame.DataFrame
DataFrame of star positions and magnitudes from 2MASS
- rafloat
Right Ascension in degrees
- decfloat
Declination in degrees
- inner_radiusfloat
Inner radius of annulus
- outer_radiusfloat
Outer area of annulus
- jwst_rogue_path_tool.plotting.plot_fixed_angle_regions(observation, angle, output_directory=None)¶
Plot the susceptibility region and targets in and around it.
Parameters¶
- observationdictionary
Dictionary of a single observation dataset
- anglefloat
Angle of attitude.
- output_directorystr
Directory to save figure to.
utils.py¶
Utility funcitons for JWST Rogue Path Tool
Authors¶
Mario Gennaro
Mees Fix
- jwst_rogue_path_tool.utils.absolute_magnitude(band_magnitude)¶
Calculate absolute magnitude from band magnitude.
Parameters¶
- band_magnitudefloat
Band magnitude value from catalog
Returns¶
- absolute_magnitudefloat
Calculated absolute magnitude of target in catalog.
- jwst_rogue_path_tool.utils.calculate_background(ra, dec, wavelength, threshold)¶
Calculate background using JWST Backgrounds Tool
- jwst_rogue_path_tool.utils.get_photmjsr(pupil, filter)¶
Get photmjsr values from filter_data.txt
Parameters¶
- pupilstr
NRC pupil name
- filterstr
NRC filter name
Returns¶
- photmjsrfloat
Flux conversion factor from DN/s to MJy/sr of filter/pupil
- jwst_rogue_path_tool.utils.get_pivot_wavelength(pupil, filter)¶
Get pivot wavelength values from filter_data.txt
Parameters¶
- pupilstr
NRC pupil name
- filterstr
NRC filter name
Returns¶
- pivot_wavelengthfloat
Pivot wavelength of filter/pupil