#!/data_systems/opt/bin/python3 """ refresh_bad_orbits_list.py Created on 2019-05 @author: Bill Barrett """ from datetime import datetime from processing_summary_emailer import AIMProcessingSummary, AIM_CIPS_DATA_ROOT from season_and_version_utils import SeasonAndVersionUtils # /aim/data/cips/south_2018/level_1p/ver_05.20/rev_04/orbit_catalog/bad_orbit_list_v05.20_r04.sav # Use IDL to restore an IDL sav file in Justin Carstens' bad orbit format file # and write out the contents IDL_COMMAND = 'idl -e "restore, \'{}\'' + \ '& for i = 0, n_elements(bad_list) - 1 do print, bad_list[i], bad_list_reason[i]"' # The year that the AIM spaceccraft was launched AIM_LAUNCH_YEAR = 2007 class BadOrbitListRefresher: """ Update the bad orbits list """ def __init__(self): """ Verify that the host this is run on can send email Get the date for which this information is valid and the date and season for the definitive data """ # Verify that the host this is run on can send eamil self.hostname = AIMProcessingSummary.verify_host() # Get the date for which this information is valid self.today = datetime.today() self.processing_date = self.today.strftime('%Y-%j') self.current_year = self.today.year self.season = SeasonAndVersionUtils.get_season(self.processing_date) def get_seasons_to_check(self, beginning_year=AIM_LAUNCH_YEAR): """ Get the list of seasons to check for bad orbits Parameters ---------- beginning_year: int the first year to check for data defaults to the year AIM was launched Returns ------- seasons_to_check : list of str the list of seasons such as 'north_2008', 'south_2012', etc to check """ seasons_to_check = [] # Get the list for year in range(beginning_year, self.current_year + 1): for hemisphere in ['north', 'south']: season = '{0}_{1}'.format(hemisphere, year) seasons_to_check.append(season) if season == self.season: break return seasons_to_check if __name__ == '__main__': """ """ BAD_ORBIT_LISTER = BadOrbitListRefresher() season_list = BAD_ORBIT_LISTER.get_seasons_to_check() for season in season_list: print(season)