mugatu package

mugatu.designmode module

class mugatu.designmode.DesignMode(label=None)[source]

Bases: object

Class to store parameters for a design mode

Parameters:

label (str) – label for design mode

Variables:
  • n_stds_min (dict) – Dictonary with the minimum number of standards for a design for each instrument (‘APOGEE’ and ‘BOSS’).

  • min_stds_fovmetric (dict) – Dictonary wih the FOV metric for the standards in a design for each instrument (‘APOGEE’ and ‘BOSS’). The FOV metric is described by three parameters, the nth neighbor to get distances to, the percentle distance to calculate and the distace to compare against for validation (in mm).

  • stds_mags (dict) – Dictonary for the min/max magnitude for the standards in a design for each instrument (‘APOGEE’ and ‘BOSS’). Indexes correspond to magntidues: [g, r, i, z, bp, gaia_g, rp, J, H, K].

  • bright_limit_targets (dict) – Dictonary for the min/max magnitude for the science targets in adesign for each instrument (‘APOGEE’ and ‘BOSS’). Indexes correspond to magntidues: [g, r, i, z, bp, gaia_g, rp, J, H, K].

  • sky_neighbors_targets (dict) – Dictonary for the parameters used to check distance between skies and all possible sources in field for each instrument (‘APOGEE’ and ‘BOSS’). Distances to targets (r, in arcseconds) must be r > R_0 * (lim - mags) ** beta, where mags is G band for BOSS and H band for APOGEE. Indexes correspond to: [R_0, beta, lim]

  • trace_diff_targets (dict) – Dictonary for the maximum magnitude difference allowed between fibers next to each ther on the chip for each instrument (‘APOGEE’ and ‘BOSS’). Here the magntidue difference is checked in the G band for BOSS and H band for APOGEE.

fromarray(arr=None)[source]

Reads an ndarray form of the object created by toarray()

fromdb(label=None)[source]

Read in parameters for design mode from db

Parameters:

label (str) – name of design mode

fromdict(designmode_dict=None)[source]

Builds from a dictionary form of the object

Parameters:

designmode_dict (dict) – dictionary form of DesignMode object created by todict()

frommanual(label=None, desmode_manual=None)[source]

Read in parameters for design mode from dictionary input

Parameters:
  • label (str) – name of design mode

  • desmode_manual (dict) – Dictonary of DesignMode parameters to be used as manual inputs to validate the design, rather than from targetdb.

toarray()[source]

Returns an ndarray form of the object

todict()[source]

Returns a dictionary form of the object

class mugatu.designmode.DesignModeCheck(FPSDesign, desmode_label, desmode_manual=None, db_query_results_boss=None, db_query_results_apogee=None)[source]

Bases: DesignMode

Parameters:
  • FPSDesign (object) – mugatu.fpsdesign.FPSDesign object with a built design.

  • desmode_label (str) – The DesignMode label from targetdb. Options for label are: bright_time, dark_plane, dark_monit, dark_rm and dark_faint.

  • desmode_manual (dict) – Dictonary of DesignMode parameters to be used as manual inputs to validate the design, rather than from targetdb.

  • db_query_results_boss (dict) – Database query results for BOSS bright neighbor check. Each index of dict is a tuple of (ras, decs, mags, catalogids) with one index for designmode and the other safety.

  • db_query_results_apogee (dict) – Database query results for APOGEE bright neighbor check. Each index of dict is a tuple of (ras, decs, mags, catalogids) with one index for designmode and the other safety.

Variables:
  • design (dict) – FPSDesign dictonary.

  • racen (float) – RA center of the field (degrees)

  • deccen (float) – DEC center of the field (degrees)

  • position_angle (float) – Position angle of the field E of N in degrees.

  • observatory (str) – Observatory where observation is taking place, either ‘LCO’ or ‘APO’.

  • obsTime (float) – Julian date of the observation.

  • rg (kaiju.robotGrid) – Kaiju robotGrid object for the design.

  • n_skies_min (dict) – Dictonary with the minimum number of skies for a design for each instrument (‘APOGEE’ and ‘BOSS’).

  • min_skies_fovmetric (dict) – Dictonary wih the FOV metric for the skies in a design for each instrument(‘APOGEE’ and ‘BOSS’). The FOV metric is described by three parameters, the nth neighbor to get distances to, the percentle distance to calculate and the distace to compare against for validation (in mm).

  • n_stds_min (dict) – Dictonary with the minimum number of standards for a design for each instrument (‘APOGEE’ and ‘BOSS’).

  • min_stds_fovmetric (dict) – Dictonary wih the FOV metric for the standards in a design for each instrument (‘APOGEE’ and ‘BOSS’). The FOV metric is described by three parameters, the nth neighbor to get distances to, the percentle distance to calculate and the distace to compare against for validation (in mm).

  • stds_mags (dict) – Dictonary for the min/max magnitude for the standards in a design for each instrument (‘APOGEE’ and ‘BOSS’). Indexes correspond to magntidues: [g, r, i, bp, gaia_g, rp, h].

  • bright_limit_targets (dict) – Dictonary for the min/max magnitude for the science targets in adesign for each instrument (‘APOGEE’ and ‘BOSS’). Indexes correspond to magntidues: [g, r, i, bp, gaia_g, rp, h].

  • sky_neighbors_targets (dict) – Dictonary for the parameters used to check distance between skies and all possible sources in field for each instrument (‘APOGEE’ and ‘BOSS’). Distances to targets (r, in arcseconds) must be r > R_0 * (lim - mags) ** beta, where mags is G band for BOSS and H band for APOGEE. Indexes correspond to: [R_0, beta, lim]

  • trace_diff_targets (dict) – Dictonary for the maximum magnitude difference allowed between fibers next to each ther on the chip for each instrument (‘APOGEE’ and ‘BOSS’). Here the magntidue difference is checked in the G band for BOSS and H band for APOGEE.

  • carton_classes (dict) – Dictonary of arrays for the carton pks in each category (i.e. science, standards and skies).

bright_neighbors(instrument, check_type='designmode', db_query=None)[source]

Check if any fibers are placed near a bright star

Parameters:
  • instrument (str) – Instrument to check sky distances. Must be ‘BOSS’ or ‘APOGEE’.

  • check_type (str) – Either ‘designmode’ for checking bright stars in catalogdb down to designmode magnitude limit, or ‘safety’ for checking bright stars in targetdb in bright star cartons.

  • db_query (peewee query) – Optionally pass the pre-queried bright stars from catalogdb or targetdb. Must include ra, dec, magnitude and id. Other option is to provide tuple of (ra,dec,magntiude,id).

Returns:

  • neigh_checks_des (np.array) – Array of booleans equal to length of 500, where order is robotID 1 to 500 robotID. True assignment valid (i.e. not near bright star), False if not valid.

  • hasFiber (np.array) – Array of booleans equal to length of 500, where order is robotID 1 to 500 robotID. True if robotID has intrument on fiber, False if not. If False, do not consider result from neigh_checks_des for this robotID

  • mag_adj_robo (np.array) – If neigh_checks_des == False, reports the magntiude of nearby bright source at the fiber position. If neigh_checks_des == True, then no value reported (where NULL = -9999.).

  • isassigned (np.array) – Array of booleans equal to length of 500, where order is robotID 1 to 500 robotID. True if robotID is assigned in grid and False if it is not.

design_mode_check_all(verbose=True)[source]

Perform all DesignMode checks for the given design.

Parameters:

verbose (boolean) – True if want print statement summarizing results of all checks.

Variables:
  • n_skies_min_check (dict) – Results of minumum sky check for each instrument.

  • min_skies_fovmetric_check (dict) – Results of sky FOV metric check for each instrument.

  • n_stds_min_check (dict) – Results of minumum standard check for each instrument.

  • min_stds_fovmetric_check (dict) – Results of standard FOV metric check for each instrument.

  • stds_mags_check (dict) – Results of standard magnitude limit check for each instrument.

  • bright_limit_targets_check (dict) – Results of science magnitude limit check for each instrument.

mag_limits(mag_metric, instrument, carton_class)[source]

Checks the if magnitude of assignments agree with design mode for some instrument and carton class

Parameters:
  • mag_metric (np.array) – Array of shape (N,M), where N=10 corresponds to magntiudes [g, r, i, z, bp, gaia_g, rp, J, H, K], and M=2 where 0th column is minimum magnitude and 1st column is maximum magnitude. If no check in certain band, use None as value.

  • instrument (str) – Instrument to check magnitudes. Must be ‘BOSS’ or ‘APOGEE’.

  • carton_class (str) – Carton class to check magnitude limits of. Must be ‘std’ or ‘science’.

Returns:

  • mag_checks (np.array) – Array of booleans equal to length of self.design. If True, assignment within magnitude limits, False if not. If assignment is not with instrument or in carton_class, will be False.

  • complete_check (np.array) – Array of str equal to length of self.design. If ‘INCOMPLETE’, then assignment either did not have all required photometry for check, or assignment is not with instrument or in carton_class.

skies_fov(instrument, return_metric=False)[source]

Checks if design meets the FOV metric for the skies for some instrument. Returns True FOV metric met, False if not. Also, if no science targets in design returns True, while no skies returns False.

Parameters:
  • instrument (str) – Instrument to FOV metric. Must be ‘BOSS’ or ‘APOGEE’.

  • return_metric (boolean) – If True, will return the FOV metric for the design.

Returns:

  • boolean – True FOV metric met, False if not. Also, if no science targets in design returns True, while no skies returns False.

  • perc_dist (float) – Percentile distance between science assignments and skies (FOV metric) for the design. Only returned if return_metric=True.

skies_min(instrument, return_metric=False)[source]

Checks if design has the required number of skies for some instrument. Returns True if number skies is greater than the minimum and False if not.

Parameters:
  • instrument (str) – Instrument to check number of sky fibers. Must be ‘BOSS’ or ‘APOGEE’.

  • return_metric (boolean) – If True, will return the number of skies in the design.

Returns:

  • boolean – True if number skies is greater than the minimum and False if not.

  • n_skies (int) – Number of skies in design, only returned if return_metric=True.

stds_fov(instrument, return_metric=False)[source]

Checks if design meets the FOV metric for the standards for some instrument. Returns True FOV metric met, False if not. Also, if no science targets in design returns True, while no standards returns False.

Parameters:
  • instrument (str) – Instrument to FOV metric. Must be ‘BOSS’ or ‘APOGEE’.

  • return_metric (boolean) – If True, will return the FOV metric for the design.

Returns:

  • boolean – True FOV metric met, False if not. Also, if no science targets in design returns True, while no standards returns False.

  • perc_dist (float) – Percentile distance between science assignments and standards (FOV metric) for the design. Only returned if return_metric=True.

stds_min(instrument, return_metric=False)[source]

Checks if design has the required number of standards for some instrument. Returns True if number standards is greater than the minimum and False if not.

Parameters:
  • instrument (str) – Instrument to check number of standard fibers. Must be ‘BOSS’ or ‘APOGEE’.

  • return_metric (boolean) – If True, will return the number of standards in the design.

Returns:

  • boolean – True if number standards is greater than the minimum and False if not.

  • n_stds (int) – Number of standards in design, only returned if return_metric=True.

mugatu.designmode.adjusted_brigh_neigh_mag(mag_bs, r, lunation)[source]

returns the approximate adjusted magntidue of a bright source at the position of a nearby fiber. This is for the piecewise appromixation used based on: https://wiki.sdss.org/pages/viewpage.action?pageId=100173069

Parameters:
  • mag_bs (float) – The magniutde in the G band for the bright star

  • r (float or np.array) – distance between fiber and bright star (in arcseconds)

  • lunation (str:) – If the designmode is bright time (‘bright’) or dark time (‘dark’)

Returns:

adjusted_mag_bs (float) – The adjusted magntiude of the bright star in SDSS r-band

mugatu.designmode.allDesignModes(filename=None, ext=1)[source]

Function to return a dictionary with all design modes

Parameters:
  • filename (str) – FITS file name to read array from (default None)

  • ext (int or str) – FITS file extension to read array from (default 1)

  • Comments

  • --------

  • OrderedDict (Returns an)

  • provided (If filename is not)

  • name (it reads from that file)

  • not (and the given extension. If)

  • database. (it reads from the)

  • available (If neither the filename is given nor the db is)

  • it

  • None. (returns)

mugatu.designmode.ang_sep(ra1, dec1, ra2, dec2)[source]

Returns angular separation between objects.

Parameters:
  • ra1 (float or np.array) – Right ascension(s) of first object(s).

  • dec1 (float or np.array) – Declination(s) of first object(s).

  • ra2 (float or np.array) – Right ascension(s) of second object(s).

  • dec2 (float or np.array) – Declination(s) of second object(s).

Returns:

sep (float or np.array) – Angular seperation between objects in degrees.

mugatu.designmode.bright_neigh_exclusion_r(mag_bs, mag_limit_r, lunation)[source]

returns the exclusion radius for a fiber around a bright star in arcseconds for a given designmode. This is for the piecewise appromixation used based on: https://wiki.sdss.org/pages/viewpage.action?pageId=100173069

Parameters:
  • mag_bs (float or np.array) – The magniutde in the G band for the bright star(s)

  • mag_limit_r (float) – Magnitude limit for the designmode in the r-SDSS band

  • lunation (str:) – If the designmode is bright time (‘bright’) or dark time (‘dark’)

Returns:

r_exclude (float or np.array) – exclusion radius in arcseconds around bright star(s)

mugatu.designmode.build_brigh_neigh_query(check_type, instrument, mag_lim, racen, deccen, observatory=None, version_catdb='1.0.0')[source]

Builds the database query needed to run bright neighbor check

Parameters:
  • check_type (str) – Either ‘designmode’ for full designmode check with all stars down to mag_lim in catalogdb, or ‘safety’ for safety check using bright stars in targetdb.

  • instrument (str) – Fiber instrument being checked. Either ‘BOSS’ or ‘APOGEE’.

  • mag_lim (float) – Magnitude limit in the r_SDSS band for BOSS or H band for APOGEE.

  • racen (float) – Field center in right ascension.

  • deccen (float) – Feild center in declination

  • observatory (str) – Observatory where observation is taking place, either ‘LCO’ or ‘APO’.

  • version_catdb (str) – catalogdb.Version.plan to use for the query

  • Outputs

  • -------

  • db_query_results (tuple) – Tuple of (ra, dec, mag, catalogid, pmra, pmdec) for the appropriate database query

mugatu.designmode.check_assign_mag_limit(mag_metric_min, mag_metric_max, assign_mag)[source]

Checks the if magnitude of one assignment agrees with design mode for some instrument and carton class

Parameters:
  • mag_metric_min (float) – The minimum magitude for the specific DesignMode.

  • mag_metric_min – The maximum magitude for the specific DesignMode.

  • assign_mag (float) – The magntiude of the assignment being checkaged against the DesignMode.

Returns:

  • targ_check (boolean) – True of the assignment magntiude passed the DesignMode for the magnitude, False if not.

  • complete_check (str) – ‘COMPLETE’ if assign_mag is value, ‘INCOMPLETE’ if Null.

mugatu.designmode.check_design_to_status(design_id)[source]

check if the design_id is done

mugatu.designmode.designid_status_valid(design_id, field_id, field_exposure)[source]

check if design_id assocatied in rsFieldAssignments file is based on ‘done’ designs in database.

Parameters:
  • design_id (int) – The design_id to be validated. If -1, then checks all possible field_exposures in the field.

  • field_id (int) – field_id for the design.

  • field_exposure (int) – field_exposure for the design.

Returns:

status (bool) – If the design_id is set correctly for the design_status.

mugatu.designmode.find_designid_status(field_id, field_exposure, assign_hash=None)[source]

Find the designid status based on a given field and field_exposure

Parameters:
  • field_id (int) – field_id for the design.

  • field_exposure (int) – field_exposure for the design.

  • assign_hash (str) – The assignment_hash for the design

Returns:

  • designid_status (int) – The designid_status for the given slot. If -1, not observed yet

  • status_des (str) – status of design in opsdb

mugatu.designs_to_targetdb module

class mugatu.designs_to_targetdb.TargetdbFieldIDs(fieldid_type=None, version_plan=None)[source]

Bases: object

Class to find available fieldids in targetdb

Parameters:
  • fieldid_type (str) – Which type of fields you are considering. Either ‘manual’ for manual commissioning fields or ‘survey’ for fields used in survey operations.

  • version_plan (str) – The targetdb.Version.plan for the fields you want to consider.

check_availability(fieldid)[source]

check if fieldid(s) are currently available in targetdb.

Parameters:

fieldid (int or list) – Single or multiple fieldids to check

Returns:

field_avail (bool or np.array) – Single or array of booleans if the fieldid(s) are available (True) or not (False).

find_next_available()[source]

Find the next availble fieldid for the fieldid_type. Optionally can be some version plan.

Returns:

fieldid (int) – Next available fieldid for the fieldid_type. This accounts for any current gaps that may be in range of fieldids.

mugatu.designs_to_targetdb.assignment_hash(ids, holeIDs)[source]

Create a unique hash for the design

Parameters:
  • ids (np.array) – carton_to_target_pks for the assignments.

  • holeIDs (np.array) – corresponding holeIDs for the assignments.

Returns:

assign_hash (str) – The assignment_hash for the design

mugatu.designs_to_targetdb.designToField_exists(design_id, field_id, plan)[source]

Check if designToField entry already exists to to ensure unique entries (i.e. one unqiue combo of design_id, field_id and version)

Parameters:
  • design_id (int) – design_id for the design

  • field_id (int) – field_id for the design

  • plan (str or targetdb.Version instance) – Either robostratgegy plan as a str or a targetdb.Version.get instance for the plan that can be used to get the version pk

Returns:

exists (boolean) – whether or not the combo of design_id, field_id and version already exists in targetdb

mugatu.designs_to_targetdb.design_status_bitmask(revalidated_design=False, replacement_design=False)[source]

function to create bitmask for design_status in targetdb.DesignModeCheckResults

Parameters:
  • revalidated_design (boolean) – Has this design been revalidated

  • replacement_design (boolean) – Is this design a replacement design for the robostrategy run

Returns:

bitmask (int) – bitmask for the desin

mugatu.designs_to_targetdb.make_desigmmode_results_targetdb(design_id, design_pass, design_valid_file_row=None, design_status=None, boss_skies_min_pass=None, boss_skies_min_value=None, boss_skies_fov_pass=None, boss_skies_fov_value=None, apogee_skies_min_pass=None, apogee_skies_min_value=None, apogee_skies_fov_pass=None, apogee_skies_fov_value=None, boss_stds_min_pass=None, boss_stds_min_value=None, boss_stds_fov_pass=None, boss_stds_fov_value=None, apogee_stds_min_pass=None, apogee_stds_min_value=None, apogee_stds_fov_pass=None, apogee_stds_fov_value=None, boss_stds_mags_pass=None, apogee_stds_mags_pass=None, boss_bright_limit_targets_pass=None, apogee_bright_limit_targets_pass=None, boss_sky_neighbors_targets_pass=None, apogee_sky_neighbors_targets_pass=None, apogee_trace_diff_targets_pass=None)[source]

add designmode check results to targetdb

mugatu.designs_to_targetdb.make_designToField(design, fieldid, exposure, field_exposure)[source]

Create a new designToField entry

Parameters:
  • design (int or targetdb.Design instance) – The design_id for the design (can be int or peewee instance)

  • fieldid (int or targetdb.Field instance) – The fieldid for the field (int) or a targetdb.Field instance for the field that can be used to get the field pk

  • exposure (int) – The exposure of this set of designs. 0th indexed

  • field_exposure (int) – The exposure of this set of designs as listed in the robostrategy design file. 0th indexed

mugatu.designs_to_targetdb.make_design_assignments_targetdb(plan, fieldid, exposure, field_exposure, desmode_label, design_ids, robotID, holeID, obsWavelength, carton, observatory, targetdb_ver=None, instr_pks=None, cart_pks=None, fiber_pks=None, idtype='carton_to_target', return_design_id=False)[source]

Add assignments for a design to targetdb.

Parameters:
  • plan (str or targetdb.Version instance) – Either robostratgegy plan as a str or a targetdb.Version.get instance for the plan that can be used to get the version pk

  • fieldid (int or targetdb.Field instance) – The fieldid for the field (int) or a targetdb.Field instance for the field that can be used to get the field pk

  • exposure (int) – The exposure of this set of designs. 0th indexed

  • field_exposure (int) – The exposure of this set of designs as listed in the robostrategy design file. 0th indexed

  • desmode_label (str) – DesignMode labe for the design.

  • design_ids (np.array) – Array of catalogids or carton_to_target_pks for the design of length N

  • robotID (np.array) – Array of the robotIDs (robotIDs in robostrategy) for the design of length N

  • holeID (np.array) – Array of holeIDs for the design of length N

  • carton (np.array) – Array of cartons for the design of length N

  • obsWavelength (np.array) – Array of obsWavelength for the design (choice of ‘BOSS’ or ‘APOGEE’) for the design of legnth N

  • targetdb_ver (dict) – Optional dictonary of pks for the targetdb version of each carton used in this design. Dict is indexed by carton names. Only needed if idtype=’catalogID’.

  • instr_pks (dict) – Optional dictonary with the isntrument pks from targetdb. Dict is indexed by instrument names.

  • cart_pks (dict or array) – Optional dictonary with the possible carton pks for the design. If dict, then indexed by carton name. Optionally can be array of carton pks same length as design entries. Only needed if idtype=’catalogID’.

  • fiber_pks (dict) – Optional dictonary with the holeID pks. Dict is indexed by holeID.

  • idtype (str) – Defines the id type used in defining the design_ids. Must be ‘catalogID’ or ‘carton_to_target’.

  • return_design_id (boolean) – Optionally return the design_id for the new entry in the database.

mugatu.designs_to_targetdb.make_design_field_targetdb(cadence, fieldid, plan, racen, deccen, position_angle, observatory, slots_exposures, replacement_field=False, overplan=None)[source]

Create a new field in targetdb. Will return warning if the field already exists in targetdb

Parameters:
  • cadence (str or targetdb.Cadence instance) – Either label of the cadence for the field (str) or a targetdb.Cadence.get instance for the label that can be used to get the cadence pk

  • fieldid (int) – The fieldid for the field

  • plan (str or targetdb.Version instance) – Either robostratgegy plan as a str or a targetdb.Version.get instance for the plan that can be used to get the version pk

  • racen (float) – Right Ascension center of the field (degrees)

  • deccen (float) – Declination center of the field (degrees)

  • position_angle (float) – Position angle of the field, East of North (degrees)

  • observatory (str or targetdb.Observatory instance) – Either label of the observatory for the field (str; either ‘apo’ or ‘lco’) or a targetdb.Observatory.get instance for the observatory label that can be used to get the observatory pk

  • replacement_field (boolean) – If the field is a replacement field. If True then will ignore check for if field exists.

  • overplan (targetdb.Overplan instance) – If this is part of an overplan, include the overplan instance for the foriegn key.

mugatu.fpsdesign module

class mugatu.fpsdesign.FPSDesign(design_pk, obsTime=None, racen=None, deccen=None, position_angle=None, observatory=None, desmode_label=None, idtype='carton_to_target', catalogids=None, ra=None, dec=None, pmra=None, pmdec=None, delta_ra=None, delta_dec=None, epoch=None, holeID=None, obsWavelength=None, priority=None, carton_pk=None, category=None, magnitudes=None, design_file=None, manual_design=False, exp=0, RS_VERSION=None, offset_min_skybrightness=0.0, year='2025-08-15')[source]

Bases: object

Class to load, validate and export a design.

Parameters:
  • design_pk (int) – The pk of the design as it appears in targetdb.

  • obsTime (float) – Julian date of the observation.

  • racen (np.float64) – Right Ascension of center of the field in degrees.

  • deccen (np.float64) – Declination of center of the field in degrees.

  • position_angle (np.float64) – Position angle of the field E of N in degrees.

  • observatory (str) – Observatory where observation is taking place, either ‘LCO’ or ‘APO’.

  • desmode_label (int) – The pk in targetdb for the observing mode for the design.

  • idtype (str) – ID type used for catalogids in design. Must be ‘catalogID’ or ‘carton_to_target’.

  • catalogids (np.array) – List of ids for a manual design in db. Default from idtype is carton_to_target.

  • ra (np.array) – List of right ascensions that correspond to catalogids. If list not provided, but catalogids for a manual design are provided, right ascensions will be pulled from targetdb.

  • dec (np.array) – List of declinations that correspond to catalogids. If list not provided, but catalogids for a manual design are provided, declinations will be pulled from targetdb.

  • pmra (np.array) – Array of proper motions in the RA axis for the targets, in milliarcsec/yr. Must be a true angle, i.e, it must include the cos(dec) term. If no proper motion, set index to zero.

  • pmdec (np.array) – Array of proper motions in the DEC axis for the targets, in milliarcsec/yr. If no proper motion, set index to zero.

  • delta_ra (np.array) – List of offsets in right ascensions that correspond to catalogids. If list not provided, but catalogids for a manual design are provided, right ascensions will be pulled from targetdb.

  • delta_dec (np.array) – List of offsets in declinations that correspond to catalogids. If list not provided, but catalogids for a manual design are provided, declinations will be pulled from targetdb.

  • epoch (np.array) – Array of epochs for the coordinates in decimal years.

  • holeID (np.array) – Fiber assignement for each target in the manual design.

  • obsWavelength (np.array) – Wavelength of observation for each fiber that correspond to catalogids. Must be either ‘BOSS’ or ‘APOGEE’.

  • priority (np.array) – Priorties for targets that correspond to catalogids.

  • carton_pk (np.array) – The carton_pks (as in targetdb) for the targets that correspond to catalogids.

  • category (np.array) – The category for each target. Can be ‘science’, ‘sky_INSTRUMENT’ or ‘standard_INSTRUMENT’

  • magnitudes (np.array) – Magnitudes of the targets. Should be of size (N, 10), where columns correspond to g, r, i, z, bp, gaia_g, rp, J, H, K band magnitudes.

  • design_file (str) – FITS file with a manual design. The file must be the same format as the rsFieldAssignments file.

  • manual_design (boolean) – Boolean if the design being validated is manual (manual_design=True) or in targetdb (manual_design=False)

  • exp (int) – Exposure number for design in file. If exp=0, assumes only 1 exposure in the design file. if exp>0, then will choose exposure exp = 1 to N.

  • RS_VERSION (str) – The version of targetdb to get designs from. If None will look for RS_VERSION enviornment variable, and if None exists will default to first entry in DesignToField for that design_id.

  • offset_min_skybrightness (float) – Minimum skybrightness targets will be offset

  • year (str) – The observation epoch to use for the robostrategy.obstime.ObsTime object in format YYYY-MM-DD

Variables:
  • design (dict) – contains all of the design inputs for Kaiju needed to validate a design.

  • rg (Kaiju RobotGrid object) – Kaiju RobotGrid with the assignments from design.

  • targets_unassigned (list) – catalogid of targets that could not be assigned due to assigned robot not being able to reach the assigned target.

  • holeID_mapping (np.array) – Mapping between robotID and holeID. Index corresponds to robotID in robotID_mapping attrobute.

  • robotID_mapping (np.array) – Mapping between robotID and holeID. Index corresponds to holeID in holeID_mapping attrobute.

  • targets_collided (list) – catalogid of targets that could not be assigned due to assigned robot to assigned target resulting in a collision.

  • valid_design (dictonary) – Same format as design dictonary, except this is validated design by Kaiju with collision/delock assignments removed.

  • design_built (booleen) – True if design dictonary has been populated, False if not.

  • hourAngle (float) – Hour angle of field center from coordio.utils.radec2wokxy.

  • positionAngle_coordio (float) – position angle of field center from coordio.utils.radec2wokxy.

  • design_errors (dict) – dictonary with errors for design. Created and filled after validation.

RobotGrid_to_valid_design()[source]

Construct valid design from Kaiju Robotgrid

bright_neigh_safety(db_query_results_boss=None, db_query_results_apogee=None, desmode_manual=None)[source]

Perform safety version of bright neighbor check on the design

build_design_db()[source]

Populate the design dictonary for design in targetdb.

Notes

This method will build a design from the db if manual_design=False

build_design_manual()[source]

Populate the design dictonary for manual design.

Notes

This function creates a manual design whether it is from user inputted catalogids, or if it is a FITS file if manual_design=True.

calculate_offsets()[source]

Calculate the offsets for which an algorithmic offset value was requested

decollide_grid()[source]

Check to see if any collisions in grid, and if so, decollide grid and record assignments that were removed

design_to_RobotGrid()[source]

Add assignments to Kaiju RobotGrid.

Notes

Adds targets to the kaiju.robotGrid.RobotGridFilledHex and assigns them to fibers based on the design dictonary.

design_to_opsdb(design)[source]

Write a validated design to opsdb

Notes

I dont know what needs to be included in opsdb yet, need to look at the schema

design_to_targetdb(cadence, fieldid, exposure)[source]

Write a validated esign to targetdb

Parameters:
  • cadence (str) – Cadence label for the field.

  • fieldid (int) – fieldid for the field.

  • exposure (int) – The exposure of this set of designs, 0th indexed.

Notes

Version above should allow for manual designs to be added under version = ‘manual’ to seperate them from robostrategy ingested designs

designmode_validate(db_query_results_boss=None, db_query_results_apogee=None, desmode_manual=None)[source]

Check all designmode parameters for a design

holeID_to_robotID(holeID, return_ind=True)[source]

return the robotID for a given holeID based on current kaiju mapping

radec_to_xy(ev)[source]

transorm radec to wok xy

Parameters:

ev (eval) – eval term to ignore unassigned fibers

Returns:

fieldWarn (boolean) – Warning if any of the transformations should be eyed with suspicion.

validate_design(designmode=True, safety=True, db_query_results_boss=None, db_query_results_apogee=None, desmode_manual=None)[source]

Validate design for deadlocks and collisions using Kaiju.

Parameters:
  • designmode (bool) – Check designmodes for the design.

  • safety (bool) – Check for bright neighbors using carton of brightest Gaia/2MASS stars in targetdb.

  • db_query_results_boss (dict) – Database query results for BOSS bright neighbor check. Each index of dict is a tuple of (ras, decs, mags, catalogids) with one index for designmode and the other safety.

  • db_query_results_apogee (dict) – Database query results for APOGEE bright neighbor check. Each index of dict is a tuple of (ras, decs, mags, catalogids) with one index for designmode and the other safety.

mugatu.exceptions module

exception mugatu.exceptions.MugatuAPIError(message=None)[source]

Bases: MugatuError

A custom exception for API errors

exception mugatu.exceptions.MugatuApiAuthError(message=None)[source]

Bases: MugatuAPIError

A custom exception for API authentication errors

exception mugatu.exceptions.MugatuDeprecationWarning[source]

Bases: MugatuUserWarning

A warning for deprecated features.

exception mugatu.exceptions.MugatuDesignError(message=None)[source]

Bases: MugatuError

A custom exception when there is a critial error in a design.

exception mugatu.exceptions.MugatuDesignModeWarning[source]

Bases: MugatuUserWarning

A warning for when a test is skipped.

exception mugatu.exceptions.MugatuDesignWarning[source]

Bases: MugatuUserWarning

A warning for when a test is skipped.

exception mugatu.exceptions.MugatuError(message=None)[source]

Bases: Exception

A custom core Mugatu exception

exception mugatu.exceptions.MugatuMissingDependency(message=None)[source]

Bases: MugatuError

A custom exception for missing dependencies.

exception mugatu.exceptions.MugatuNotImplemented(message=None)[source]

Bases: MugatuError

A custom exception for not yet implemented features.

exception mugatu.exceptions.MugatuSkippedTestWarning[source]

Bases: MugatuUserWarning

A warning for when a test is skipped.

exception mugatu.exceptions.MugatuUserWarning[source]

Bases: UserWarning, MugatuWarning

The primary warning class.

exception mugatu.exceptions.MugatuWarning[source]

Bases: Warning

Base warning for Mugatu.