def __init__(self): ''' Attempts to set station.info location to directory in the environment variable GIPSY_STA_INFO. If it can't find the file, logs error, which throws CleanShutDownRequest. ''' if os.environ['GIPSY_STA_INFO']: self.sta_db = os.environ['GIPSY_STA_INFO']+'/station.info' if not os.path.isfile(self.sta_db): Logger.error(" Can't find station database at `%s'. Please check and adjust code / links accordingly.\n\ Note that this is a fixed-width formatted file!", 23)
def calculate_vertical_antenna_height(self): if (self.ht_code != "DHARP"): p1 = subprocess.Popen([ "slant2vert_height.sh", "%s" % (self.ant_ht), "%s" % (self.ant_type), "%s" % (self.ht_code)], stdout=subprocess.PIPE) output,err = p1.communicate() #Error Checking if len(output) == 0: Logger.error("Couldn't calculate vertical height for %s with \ antenna type %s and height code %s " % (self.site_id, self.ant_type, self.ht_code), 4) if err != None: Logger.error(err, 3) #done! self.vert_ht = float(output)
def get_record(self, site_id, start_time, end_time): ''' Reads station.info file, finds site, creates record ''' p1 = subprocess.Popen(["grep", "^ "+site_id, self.sta_db], stdout=subprocess.PIPE) output,err = p1.communicate() #Error Checking if len(output) == 0: Logger.error("Couldn't find %s in %s" % (site_id, self.sta_db), 4) if err != None: Logger.error(err, 3) for l in output.splitlines(): rec = StationRecord(l) #return the record that covers the current start time if start_time >= rec.sess_start and end_time <= rec.sess_end: return rec Logger.warning("Could not find an entry for site %s between %s - %s in station db %s ." % (site_id, start_time, end_time, self.sta_db))
def __init__(self, raw_file): #assign file name if os.path.isfile(raw_file): self.__raw_file__ = raw_file else: Logger.error("File `%s' does not exist." % raw_file, 23) #figure out paths to binaries proc = subprocess.Popen(['which', 'teqc'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.teqc_bin, err = proc.communicate() if len(self.teqc_bin) == 0 : Logger.error("Can't find teqc binary", 2) if err != None: Logger.error(err, 3) proc = subprocess.Popen(['which', 'teqc'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.gzip_bin, err = proc.communicate() if len(self.gzip_bin) == 0 : Logger.error("Can't find gzip binary", 2)