;docformat = 'rst rst' ;+ ; Given a date in the la date format "yyyy/doy-hh:mm:ss" return the corresponding ; AIM CIPS season. ; ; :Author: ; Chris Jeppesen, Bill Barrett ;- ;+ ; :Params: ; la_date: in, required, type=string ; A date in the la date format "yyyy/doy-hh:mm:ss". ; :Keywords: ; expected: in, optional, type=boolean ; If the hemisphere flag is incorrect, force the output to the ; correct season rather than 'anomalous'. ; hemisphere_flag: in, optional, type=character ; 'N' or 'S' to indicate whether or not the day should be ; northern or southern hemisphere. The flag is case insensitive. ; ; :Returns: ; A string such as "south_2014" or "north_2015" if the inputs are consistent. ; It will return 'anomalous' if the hemisphere flag is set to the opposite ; value from the what be expected from the date and the expected flag is ; not set. ;- FUNCTION get_season, la_date, hemisphere_flag=hemisphere_flag, expected=expected ; The input should be in la date format which means that it should start with the year, ; followed by a separator character, followed by the day of year and after that ; another separator character. ; Use a regular expression to extract them from the string regex = "^([[:digit:]]+)[[:punct:]]([[:digit:]]+)[[:punct:]]" regex_result = stregex(strtrim(la_date, 2), regex ,/SUBEXPR,/EXTRACT) year = fix(regex_result[1]) day_of_year = fix(regex_result[2]) ; If a day isn't north, then it is south ; Arbitrary days for the beginning and end of the north season, usually ; the date of the equinoxes. if (year mod 4) eq 0 && ((year mod 100) ne 0 || ((year / 100) mod 4) eq 0) then begin north_start = 80 north_end = 266 endif else begin north_start = 79 north_end = 265 endelse ; 2016/07/15 email from Justin Carstens: ; For the GW processing I’d prefer if they were placed in the directory for the hemisphere ; they were actually in. Prior to continuous imaging mode, the most active time for GW ; activity is near the equinox hemisphere switch, so we definitely don’t want to throw them out. if ~keyword_set(expected) && KEYWORD_SET( hemisphere_flag ) && $ la2usec(la_date) lt !first_continuous_imaging_timestamp THEN $ hemisphere = hemisphere_flag eq 'N' ? 'north_' : 'south_' $ else hemisphere = day_of_year GE north_start && day_of_year LE north_end ? 'north_' : 'south_' ; Days early in the year are part of the previous year's south season IF day_of_year LT north_end && hemisphere eq 'south_' THEN year = year - 1 RETURN, hemisphere + string(year,format='(%"%04d")') END