Ska.report_ranges

Tiny utilities to work with the standard timeranges expected in FOT reports. These utilities change back and forth from string specifications (e.g. “2009-Q1” for the first quarter of 2009) and “timerange” dictionaries which are of the form

{ ‘type’ : ‘quarter’,
‘start’: mx.DateTime of the start time,
‘stop’ : mx.DateTime of the stop time,
‘year’ : 2009
‘subid’ : ‘Q1’
}
Ska.report_ranges.get_next(range)

Find the time range after the given one

Parameters:range – timerange dictionary
Return type:timerange dictionary
Ska.report_ranges.get_prev(range)

Find the time range before the given one

Parameters:range – timerange dictionary
Return type:timerange dictionary
Ska.report_ranges.get_update_ranges(days=365)

Find all of the day ranges from now-N days to now.

Parameters:days – N days back as starting point
Return type:dict of labeled day ranges
Ska.report_ranges.in_month(ref_date)

which month contains a reference date

Parameters:ref_date – mx.DateTime reference date
Return type:range_string e.g. 2007-M12
Ska.report_ranges.in_quarter(ref_date)

which FOT quarter contains a reference date

Parameters:ref_date – reference date
Return type:range_string e.g. 2009-Q1
Ska.report_ranges.in_semi(ref_date)

which FOT half-year contains a reference date

Parameters:ref_date – mx.DateTime reference date
Return type:range_string e.g. 2009-S1
Ska.report_ranges.in_year(ref_date)

which year contains a reference date

Parameters:ref_date – mx.DateTime reference date
Return type:range_string e.g. ‘2010’
Ska.report_ranges.month_range(year, month)

month range

Parameters:
  • year – year
  • month – integer month
Return type:

timerange dictionary

Ska.report_ranges.quarter_range(year, quarter)

range of a FOT quarter

Parameters:
  • year – integer year
  • quarter – 1,2,3, or 4
Return type:

timerange dictionary

Ska.report_ranges.semi_range(year, semi)

range of a FOT half-year

Parameters:
  • year – integer year
  • semi – 1,2
Return type:

timerange dictionary

Ska.report_ranges.timerange(rstring)

range from string specifier

2010-M08 -> range of August 2010
2009-Q1 -> range of first quarter, 2009
2001-S1 -> range of first “semi” 2001
2008 -> range of year 2008
Parameters:rstring – range string
Return type:timerange dictionary
Ska.report_ranges.year_range(year)

find year start, stop

Parameters:year – int year
Return type:timerange dictionary

Previous topic

Ska.quatutil

Next topic

Ska.Sun