def decommutation(filename_from, filename_to, time_slot_start, time_slot_end, shortname): """Perform decommutation on *filename_from* and save the result in *filename_to*. """ import pysdh2orbnum LOG.info("Decommuting "+filename_from) (handle, tempname) = tempfile.mkstemp(prefix="decommutation", suffix=".par", dir=WORKING_DIR) os.close(handle) handle = open(tempname, "w") handle.write("1,0,0,0,0,0,0,0,0,0,0,1\n") handle.write("10,11,15,15,16,0,0,13,0,0,0,14\n") handle.write(str(time_slot_start.year) + "\n") handle.write("0\n") satpos_file = get_satpos_file(time_slot_start, shortname) formated_date = time_slot_start.strftime("%d/%m/%y %H:%M:%S.000") orbit_start = str(pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) satpos_file = get_satpos_file(time_slot_end, shortname) formated_date = time_slot_end.strftime("%d/%m/%y %H:%M:%S.000") orbit_end = str(pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) handle.write(orbit_start + "," + orbit_end + "\n") handle.close() decom = "$AAPP_PREFIX/AAPP/bin/decommutation" cmd = " ".join(["cd " + WORKING_DIR + ";", decom, "ATOVS", tempname, filename_from]) LOG.debug("Running " + cmd) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) shutil.move(os.path.join(WORKING_DIR, "hrpt.l1b"), filename_to) os.remove(tempname) LOG.debug("Decommutation done")
def decommutation(filename_from, filename_to, time_slot_start, time_slot_end, shortname): """Perform decommutation on *filename_from* and save the result in *filename_to*. """ import pysdh2orbnum LOG.info("Decommuting " + filename_from) (handle, tempname) = tempfile.mkstemp(prefix="decommutation", suffix=".par", dir=WORKING_DIR) os.close(handle) handle = open(tempname, "w") handle.write("1,0,0,0,0,0,0,0,0,0,0,1\n") handle.write("10,11,15,15,16,0,0,13,0,0,0,14\n") handle.write(str(time_slot_start.year) + "\n") handle.write("0\n") satpos_file = get_satpos_file(time_slot_start, shortname) formated_date = time_slot_start.strftime("%d/%m/%y %H:%M:%S.000") orbit_start = str( pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) satpos_file = get_satpos_file(time_slot_end, shortname) formated_date = time_slot_end.strftime("%d/%m/%y %H:%M:%S.000") orbit_end = str( pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) handle.write(orbit_start + "," + orbit_end + "\n") handle.close() decom = "$AAPP_PREFIX/AAPP/bin/decommutation" cmd = " ".join( ["cd " + WORKING_DIR + ";", decom, "ATOVS", tempname, filename_from]) LOG.debug("Running " + cmd) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) shutil.move(os.path.join(WORKING_DIR, "hrpt.l1b"), filename_to) os.remove(tempname) LOG.debug("Decommutation done")
def get_orbit(time_slot, shortname): import pysdh2orbnum formated_date = time_slot.strftime("%d/%m/%y %H:%M:%S.000") satpos_file = get_satpos_file(time_slot, shortname) return str(pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file))
def get_orbit(time_slot, shortname): import pysdh2orbnum formated_date = time_slot.strftime("%d/%m/%y %H:%M:%S.000") satpos_file = os.path.join(SATPOS_DIR, "satpos_" + shortname + time_slot.strftime("_%Y%m%d") + ".txt") return str(pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file))
def calibration_navigation(filename, time_slot, shortname): """Perform calibration on *filename* """ import pysdh2orbnum LOG.info("Calibrating " + filename) formated_date = time_slot.strftime("%d/%m/%y %H:%M:%S.000") satpos_file = get_satpos_file(time_slot, shortname) LOG.debug(formated_date) LOG.debug(satpos_file) orbit_number = str( pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) avhrcl = ("cd /tmp;" + "$AAPP_PREFIX/AAPP/bin/avhrcl -c -l -s " + shortname + " -d " + time_slot.strftime("%Y%m%d") + " -h " + time_slot.strftime("%H%M") + " -n " + orbit_number + " " + filename) LOG.debug("Running " + avhrcl) proc = subprocess.Popen(avhrcl, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) anacl1 = ("cd /tmp;" + "$ANA_PATH/bin/ana_lmk_loc -D " + filename) LOG.debug("Running " + anacl1) proc = subprocess.Popen(anacl1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) anacl2 = ("cd /tmp;" + "$ANA_PATH/bin/ana_estatt -s " + shortname + " -d " + time_slot.strftime("%Y%m%d") + " -h " + time_slot.strftime("%H%M") + " -n " + orbit_number) LOG.debug("Running " + anacl2) proc = subprocess.Popen(anacl2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) avhrcl2 = ("cd /tmp;" + "$AAPP_PREFIX/AAPP/bin/avhrcl -l -s " + shortname + " -d " + time_slot.strftime("%Y%m%d") + " -h " + time_slot.strftime("%H%M") + " -n " + orbit_number + " " + filename) LOG.debug("Running " + avhrcl2) proc = subprocess.Popen(avhrcl2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err)
def calibration_navigation(filename, start_time, shortname): """Perform calibration on *filename* """ import pysdh2orbnum formated_date = start_time.strftime("%d/%m/%y %H:%M:%S.000") satpos_file = os.path.join(SATPOS_DIR, "satpos_" + shortname + start_time.strftime("_%Y%m%d") + ".txt") LOG.debug(formated_date) LOG.debug(satpos_file) orbit_number = str(pysdh2orbnum.sdh2orbnum(shortname, formated_date, satpos_file)) avhrcl = ("cd /tmp;" + "$AAPP_PREFIX/AAPP/bin/avhrcl -c -l -s " + shortname + " -d " + start_time.strftime("%Y%m%d") + " -h " + start_time.strftime("%H%M") + " -n " + orbit_number + " " + filename) LOG.debug("Running " + avhrcl) proc = subprocess.Popen(avhrcl, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) anacl1 = ("cd /tmp;" + "$ANA_PATH/bin/ana_lmk_loc -D " + filename) LOG.debug("Running " + anacl1) proc = subprocess.Popen(anacl1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) anacl2 = ("cd /tmp;" + "$ANA_PATH/bin/ana_estatt -s " + shortname + " -d " + start_time.strftime("%Y%m%d") + " -h " + start_time.strftime("%H%M") + " -n " + orbit_number) LOG.debug("Running " + anacl2) proc = subprocess.Popen(anacl2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err) avhrcl2 = ("cd /tmp;" + "$AAPP_PREFIX/AAPP/bin/avhrcl -l -s " + shortname + " -d " + start_time.strftime("%Y%m%d") + " -h " + start_time.strftime("%H%M") + " -n " + orbit_number + " " + filename) LOG.debug("Running " + avhrcl2) proc = subprocess.Popen(avhrcl2, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() if out: LOG.debug(out) if err: LOG.error(err)