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 translate(self, site_record): ''' runs the actual translation of the file from some native format into rinex (output to standard rinex file name) ''' #ensure we have meta info... if not self.meta_info: self.meta() #figure out what receiver we are translating format_code = const.TEQC_format_translation_map[self.meta_info[const.TEQC_f_format]] #make rinex filenames file_base = "%s%s%s.%s" % ( site_record.site_id.lower(), self.meta_info[const.TEQC_f_start].strftime("%j"), self.get_hour_logged(), self.meta_info[const.TEQC_f_start].strftime("%y")) rnx_file = file_base + "o" nav_file = file_base + "n" subprocess.call("teqc "+ format_code+" "+ self.obs_string+" "+ self.sv_string+" "+ "-week %d " % self.meta_info[const.GPSweek] + "+nav %s " % nav_file + "-O.mo %s " % site_record.site_id.upper() + "-O.mn %s " % site_record.site_id.upper() + "-O.rt '%s' " % site_record.rcx_type + "-O.rn %s " % site_record.rcx_sn + "-O.at '%s' " % site_record.ant_type + "-O.an %s " % site_record.ant_sn + "-O.pe %f %f %f " % (site_record.vert_ht, site_record.ant_east, site_record.ant_north) + "-O.o '%s' " % site_record.operator + "-O.ag '%s' " % site_record.agency + self.comment_string() + self.__raw_file__ +" > %s " % rnx_file, shell=True) subprocess.call("gzip -f "+ rnx_file, shell=True) subprocess.call("gzip -f "+ nav_file, shell=True) Logger.info("Info: created `%s.gz' and `%s.gz'" % (rnx_file, nav_file))
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)
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 add_observables_string(self, obs_string): if self.__obs_match__(obs_string): self.obs_string = obs_string else: Logger.warning("`%s' not supported by teqc, check `teqc -help'. Using default `%s' " % (obs_string, self.obs_string))
def add_sv_string(self, sv_string): if self.__sv_match__(sv_string): self.sv_string = sv_string else: Logger.warning("`%s' not supported by teqc, check `teqc -help'. Using default `%s' " % (sv_string, self.sv_string))
sys.exit(2) ##interpret command line for opt, arg in opts: #HELP if opt in ("-h", "--help"): usage() sys.exit(2) elif opt in ("-s", "--site"): site_id = arg.upper() #EVENT elif opt in ("-f", "--file"): raw_file = str(arg) #quite elif opt in ("-q", "--quiet"): Logger.off() #unknown else: assert False, "unhandled option: `%s'" % opt Logger.info("-"*80) Logger.info("Info: Working on file `%s' for site `%s'" % (raw_file, site_id)) #+# create station.info interface sta_db = None try: sta_db = StationDB() except CleanShutdownRequest: print "Aborting." sys.exit()