pyger package

Submodules

pyger.base module

class pyger.base.ConstraintModel(name, sim_inputs, limits, max_dwell_ksec)[source]

Bases: object

calc_dwell1_T0s(start)[source]

Calculate the starting temperature vectors for the ensemble of pitch profiles at the given start time. Creates sim_inputs[][‘dwell1_T0s’] values.

calc_dwell1_stats(pitch_bins)[source]
calc_dwells1(start, stop, times, pitches1, i_sims)[source]

Calculate initial dwell temperatures.

Parameters:
  • start – Chandra.DateTime object for simulation start time
  • stop – Chandra.DateTime object for simulation stop time
  • times – Numpy array of times for which to calculate temperatures
  • pitches1 – Numpy array of pitch values to be simulated
  • i_sims – List of indices into sim_inputs to use for each simulation. Each i_sim index is paired with a pitch value so len(pitches1) == len(i_sims).

These are the initial dwell model runs that are used to generate the traditional pyger plots (in conjunction with find_limit_crossings function).

Allowed duration is calculated by a separate function “find_limit_crossings”. This function is run at the end of calc_dwells1, however since full dwell data is also saved, one can recalculate allowed dwell time (initial dwell) for different limit sets.

calc_dwells2(msid, start, stop, times, pitch_num, hot_dwell_temp_ratio, T_cool_ratio, T_cool_temp=None, pitch_range=None, match_cool_time=True, **statekw)[source]

Calculate model temperature at “non-hot” pitch ranges, starting at hot conditions

Parameters:
  • msid – MSID for which to calculate cooling times
  • start – Chandra.DateTime object for cooldown simulation start time
  • stop – Chandra.DateTime object for cooldown simulation stop time
  • times – Numpy array of times for which to calculate temperatures, not necessarily the same times as used in the initial dwell
  • pitch_num – Number of cool pitch values to simulate for each hot dwell
  • hot_dwell_temp_ratio – Time ratio during hot dwell for which to extract cooldown dwell starting conditions. This allows one to initiate a cooldown simulation at any point during a hot dwell, not just when the hot dwell reaches a thermal limit.
  • T_cool_ratio – Temperature ratio with respect to the temperature increase during each hot dwell, used to calculate the point at which a simulated cooldown dwell has “cooled”. Ultimately, the reported cooling time is the time it takes for the MSID to reach the “cooled” temperature, starting at the given hot conditions. A ratio of 0.9 means the MSID has to have cooled back down 90% to the original hot dwell starting temperature.
  • T_cool_temp – Temperature to which cooling time is always calculated; this overrides the T_cool_ratio method.
  • pitch_range – Two element list or tuple defining target cooling pitch range. This allows one to override the default cool pitch values.
  • match_cool_time – Flag used to indicate whether or not the user wants to clip the time from t=0 to the time where the temperature reaches the T_cool_ratio from the heatup dwell time. This facilitates an equal comparison of dwell times (i.e. delta temp for heatup equals delta temp for cooldown so time comparisons are relevant).
  • **statekw

    Model state information; allows one to specify different states for the cooldown dwell. For example one could simulate the initial dwell with 6 ccds and simulate the cooldown dwell with 4 ccds.

Returns:

Numpy recarray containing cooldown simulation information

Regarding pitch values used: 1) By default pitch values previously used are re-used as the sample set for the cooldown

dwells. This makes dividing up the hot vs. cold pitch values much easier. Dividing up the pitch values between hot and “not hot” (i.e. cold) pitch values reduces the number of model runs since there is no need to run a “cooldown” dwell for at hot pitch value. If new pitch values were used, the current constraint profile would have to be mapped in some fashion, complicating the process of finding the required balance of hot and cold time. Also, it doesn’t make sense to run a cooldown dwell for an already cold dwell.
  1. Since some constraints are strongly dependant on other factors besides pitch (e.g. dpa), the ability to override the default behavior described above is built in. If this override is triggered, the “pitch_range” keyword should return a two element list or tuple including the minimum and maximum pitch to use for the cooldown simulations. Pitch values are chosen from those used in the original simulations.

This second set of dwells is sometimes referred to “cooldown” dwells or sims since the original intent was to determine the time to cool from hot conditions.

Regarding time span of second set of dwells (“cooldown dwells”): Cooldown dwells are run from “start” to “stop”; both are inputs to this function. The total cooling time (defined in start, stop, times) should be equal to or longer than the maximum dwell time used in the initial dwell so cooling times are adequately mapped.

Regarding filtering: Dwells that have zero duration (as specifed in the self.dwells1 datastructure) are filtered out. These will likely have final temperatures that are higher than the specified limit.

find_limit_crossings(limits=None)[source]

Determine which dwells reach specified MSID limits.

Parameters:limits – dict of limits, keys are msids

This function modifies the dwells1 datastructure by filling in constraint information

find_long_hot_pitch_dwells(msid, perc=0.2)[source]

Select the initial hot pitch sims that start with a low temperature (bottom 20%)

Parameters:
  • msid – MSID used to filter hot pitch dwells
  • perc – fraction of starting temperatures (0.2 = 20% lowest temperatures)
Returns:

index into self.dwells1 datastructure

This returns the index into the self.dwells1 datastructure, indicating which of those sims that reached a limit, started at the specified percentile/fraction of coldest starting temperatures for the MSID indicated.

Note about the data returned: Invariably, most of these will sims will have startedwithin a narrow pitch range before “maneuvering” to the simulated “hot” pitch. This isimportant to keep in mind since these lowest temperatures will often not be able to be reached during the second dwell set of simulations (think of these as the “cooldown” simulations). This is the purpose of adding a pad to the “cooled” value when calculating cooldown times.

n_sim[source]

pyger.clogging module

class pyger.clogging.NullHandler(level=0)[source]

Bases: logging.Handler

emit(record)[source]
pyger.clogging.config_logger(name, format='%(message)s', datefmt=None, stream=<open file '<stdout>', mode 'w' at 0x2b1c2f5e6150>, level=20, filename=None, filemode='w', filelevel=None, propagate=False)[source]

Do basic configuration for the logging system. Similar to logging.basicConfig but the logger name is configurable and both a file output and a stream output can be created. Returns a logger object.

The default behaviour is to create a StreamHandler which writes to sys.stdout, set a formatter using the “%(message)s” format string, and add the handler to the name logger.

A number of optional keyword arguments may be specified, which can alter the default behaviour.

Parameters:
  • name – Logger name
  • format – handler format string
  • datefmt – handler date/time format specifier
  • stream – initialize the StreamHandler using stream (None disables the stream, default=sys.stdout)
  • level – logger level (default=INFO).
  • filename – create FileHandler using filename (default=None)
  • filemode – open filename with specified filemode (‘w’ or ‘a’)
  • filelevel – logger level for file logger (default=``level``)
  • propagate – propagate message to parent (default=False)
Returns:

logging.Logger object

pyger.make_sim_inputs module

Generate a set of simulation profiles from which starting conditions can be calculated.

pyger.make_sim_inputs.K2F(k)[source]
pyger.make_sim_inputs.get_sim_data(start, stop, n_days, sim_start_times, sim_stop_times, model)[source]

Gather the state and telemetry data required to propagate simulation starting values

Parameters:model – Dictionary of model information from “constraint_models”

This gathers the state and telemetry data for one model for N dwells, where N is the number of suitable dwells found in telemetry in the specified time span (usually most recent year of data).

pyger.make_sim_inputs.get_sim_times(start, stop, n_days, min_dwell_sec, max_dwell_num)[source]

Generate a list of simulation start and stop times

Simulation stop times are generated by finding all dwells with minimum durations specified by “min_dwell_sec”. A minimum dwell time is specified to filter out intermediate states during maneuvers. A default value of 1Ks is used since this is the smallest dwell mission planning will generally schedule.

Simulation start times are calculated by subtracting “n_days” in seconds from the simulation stop times.

These start and stop times are used to propagate starting temperatures for the desired date in the pyger simulation (not calculated in sim_inputs() ).

sim_start_times and sim_stop_times are lists of time values in units of seconds

pyger.make_sim_inputs.get_states(start, stop, n_days, state_vals=['pitch'])[source]

Fetch states for the specified values.

Parameters:state_vals – List of state types to query

Pitch is used as a default in the case where this function is called without a state value.

An extra day before the start time and an extra hour after the stop time are fetched to prevent missing data problems.

pyger.make_sim_inputs.get_telemetry(start, stop, n_days, sim_stop_times, msids)[source]

Fetch telemetry for the specified msids.

Parameters:msids – List of msids to fetch

An extra day before the start time and an extra hour after the stop time are fetched to prevent missing data problems.

pyger.make_sim_inputs.make_sim_inputs(start=None, stop=None, sim_file='sim_inputs.pkl', n_days=3, min_dwell_sec=1000, max_dwell_num=300)[source]

Generate a set of simulation profiles from which starting conditions can be calculated.

Parameters:
  • start – Start date for time period to find simulation dwells
  • stop – Stop date for time period used to find simulation dwells
  • sim_file – Filename to save simulation profiles (pickle file)
  • n_days – Number of days of dwell history to save for propagation
  • min_dwell_sec – Minimum number of seconds to use as a propagation ending dwell
  • max_dwell_num – Maximum number of sample dwells to save

Generates a dictionary, “sim_inputs” of simulation profiles for each model in the following form:

>>> sim_inputs
Returns a dictionary of simulation profiles for each model (too long to show).
>>> sim_inputs[modelname]
Returns a list of simulation profiles (too long to show). "modelname" is the name of the
model queried.
>>> sim_inputs[modelname][sim_number]
{'msids', 'states', 'T0s', 'tstart', 'T1s' 'tstop'}
pyger.make_sim_inputs.write_sim_inputs(sim_file, sim_inputs)[source]

Write sim input data to a pickle file.

pyger.pyger module

Calculate Chandra dwell times given thermal constraints

class pyger.pyger.ConstraintACISFP(sim_inputs, limits, max_dwell_ksec, n_ccd=6, dh_heater=True)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintAca(sim_inputs, limits, max_dwell_ksec)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintDEA(sim_inputs, limits, max_dwell_ksec, n_ccd=6)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintDPA(sim_inputs, limits, max_dwell_ksec, n_ccd=6)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintFwdblkhd(sim_inputs, limits, max_dwell_ksec)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintPSMC(sim_inputs, limits, max_dwell_ksec, n_ccd=6, dh_heater=True)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintTank(sim_inputs, limits, max_dwell_ksec)[source]

Bases: pyger.base.ConstraintModel

class pyger.pyger.ConstraintTcylaft6(sim_inputs, limits, max_dwell_ksec)[source]

Bases: pyger.base.ConstraintModel

pyger.pyger.CtoF(cs)[source]
pyger.pyger.FtoC(cs)[source]
pyger.pyger.calc_constraints(start='2013:001', n_sim=500, dt=1000.0, max_tcylaft6=999.0, max_1pdeaat=999.0, max_1dpamzt=999.0, max_1deamzt=999.0, max_pftank2t=999.0, max_aacccdpt=999.0, max_4rt700t=999.0, max_fptemp_11=999.0, n_ccd=6, dh_heater=True, sim_file='sim_inputs.pkl', max_dwell_ksec=200.0, min_pitch=45, max_pitch=169, bin_pitch=2, constraint_models=('psmc', 'dpa', 'dea', 'tank', 'aca', 'fwdblkhd', 'tcylaft6', 'acisfp'))[source]

Calculate allowed dwell times coming out of perigee given a set of constraint models.

Parameters:
  • start – date at which to perform the constraint simulations
  • n_sim – number of Monte-Carlo simulations of (pitch, starting condition) (default=500)
  • dt – step size used in thermal model computations (default=1000 sec)
  • max_tcylaft6 – TCYLAFT6 planning
  • max_1pdeaat – 1PDEAAT planning limit
  • max_1dpamzt – 1DPAMZT planning limit
  • max_1deamzt – 1DEAMZT planning limit
  • max_pftank2t – PFTANK2T planning limit
  • max_aacccdpt – ACA CCD planning limit
  • max_4rt700t – OBA forward bulkhead planning limit
  • max_acisfp – ACIS Focal Plane limit
  • n_ccd – number of ACIS CCDs being used
  • max_dwell_ksec – maximum allowed dwell time (default=200 ksec)
  • sim_file – simulation inputs file from “pyger make” (default=sim_inputs.pkl)
  • min_pitch – minimum pitch in simulations (default=45)
  • max_pitch – maximum pitch in simulations (default=169)
  • bin_pitch – pitch bin size for calculating stats (default=2)
  • constraint_models – constraint models, default=(‘psmc’, ‘dpa’, ‘dea’, ‘tank’, ‘aca’, ‘fwdblkhd’, ‘tcylaft6’, ‘acisfp’)
Returns:

dict of computed constraint model objects

pyger.pyger.calc_constraints2(constraints, start='2013:001', n_ccd=None, dh_heater=True, max_dwell_ksec=400.0, pitch_num=50, pitch_range=None, hot_dwell_temp_ratio=0.9, T_cool_ratio=0.9, constraint_models=('psmc', 'dpa', 'dea', 'tank', 'aca', 'fwdblkhd', 'tcylaft6', 'acisfp'), msids=('tcylaft6', '1pdeaat', '1dpamzt', '1deamzt', 'pftank2t', 'aacccdpt', '4rt700t', 'acisfp_11'))[source]

Calculate allowed dwell times coming out of perigee given a set of constraint models.

Parameters:
  • start – date at which to perform the constraint simulations
  • n_ccd – number of ACIS CCDs being used
  • max_dwell_ksec – maximum allowed dwell time (default=200 ksec)
  • pitch_num – Number of cool pitch values to simulate for each hot dwell
  • pitch_range – Two element list or tuple defining target cooling pitch range. This allows one to override the default cool pitch values.
  • hot_dwell_temp_ratio – Time ratio during hot dwell for which to extract cooldown dwell starting conditions. This allows one to initiate a cooldown simulation at any point during a hot dwell, not just when the hot dwell reaches a thermal limit.
  • T_cool_ratio – Temperature ratio with respect to the temperature increase during each hot dwell, used to calculate the point at which a simulated cooldown dwell has “cooled”. Ultimately, the reported cooling time is the time it takes for the MSID to reach the “cooled” temperature, starting at the given hot conditions. A ratio of 0.9 means the MSID has to have cooled back down 90% to the original hot dwell starting temperature.
  • constraint_models – constraint models included
Returns:

dict of computed constraint model objects

pyger.pyger.calc_dwell2_cool_stats(dwell2_case)[source]

Calculate relevant statistics for “cooldown” dwell simulations.

Parameters:dwell2_case – This is a Numpy recarray representing the output of calc_constraints2() for a single MSID. If running calc_constraints2() for multiple MSIDs, run calc_dwell2_stats() for each MSID individually.
Returns:Numpy recarray of relevant statistical data
pyger.pyger.calc_dwell2_hot_stats(dwell2_case)[source]

Calculate relevant statistics for hot dwells used to seed cooldown simulations.

Parameters:dwell2_case – This is a Numpy recarray representing the output of calc_constraints2() for a single MSID. If running calc_constraints2() for multiple MSIDs, run calc_dwell2_stats() for each MSID individually.
Returns:Numpy recarray of relevant statistical data

Although the hot dwell data was already calculated and is present in the dwells1 datastructure, the full hot dwell durations are not 100% comparable to the cooldown dwells due to the cooldown temperature ratio (T_cool_ratio) used to determine when a cooldown dwell has reached “close enough” to the original starting temperature. The comparable hot dwell time has a portion of the initial dwell time “clipped” from the total duration. The amount of time clipped is equal to the amount of time it would take to reach the “close enough” cooldown temperature during the hot dwell starting at the dwell1 T0.

pyger.pyger.hour_min_to_sec(hm)[source]

Convert string in format hh:mm to seconds

pyger.pyger.load_pyger_pickle(filename)[source]

Load pyger data from pickle file back into object compatible with pyger plotting methods

Parameters:filename – File name of pickled output from calc_constraints()

This is only meant to be used to read in the initial constraints object produced by calc_constraints(), not the cooldown data produced by calc_constraints2(). The data prduced by calc_constraints2() should be able to be read in with a simple pickle.load() function.

pyger.pyger.merge_dwells1(constraints)[source]

Merge the dwells in the constraints list, finding the shortest from among the constraints. :param constraints: list of ModelConstraint objects :returns: NumPy recarray of dwells with pitch, duration, constraint_name columns

pyger.pyger.save_pyger_pickle(constraints, filename)[source]

Save pyger data to pickle file

Parameters:
  • constraints – This can be either the output from calc_constraints() or a numpy.core.records.recarray object, which is output by calc_constraints2()
  • filename – Name of pickle file to write data to

pyger.pyger_cases module

class pyger.pyger_cases.PostPyger(cases, pickledir)[source]

Bases: object

Consolidate results from a set of models

calc_stats()[source]
get_case_frame(case)[source]
get_constraint_info()[source]
pyger.pyger_cases.read_cases(csv_casefile)[source]
pyger.pyger_cases.run_pyger_cases(cases, savedwell1=False)[source]

Module contents

pyger.get_options(args=None)[source]
pyger.main(args=None)[source]

Table Of Contents

Previous topic

Pyger Documentation

This Page