def allLoc(filen): print "Entering " + __name__ + ".MastInstLoc.py" print "Running allLoc" print "filen: ", filen loco = 'rover2orbital' print "loco: ", loco site = parseVicarLabel.getSite(filen) print "Site Index: ", site drive = parseVicarLabel.getDrive(filen) print "Drive Index: ", drive venue = "ops" print "PLACES Venue: ", venue inst = parseVicarLabel.getInstrumentId(filen) print "Instrument: ", inst pos = InstPos(filen) if pos == '': sid = 'Cpoint' pos = str(parseVicarLabel.getCameraCPoint(filen)) else: sid = instruments.InstDic[inst][4] pos = pos.tolist() pos = pos.replace("]", ")") pos = pos.replace(" ", "") x, y, z = places.getLocoSiteTranslation(venue, pos, site, drive, loco) p2xyz_status = 0 print "Leaving " + __name__ + ".MastInstLoc.py and returing x,y,z: ", x, y, z return x, y, z, sid, p2xyz_status
def main(): try: os.environ['R2LIB'] except KeyError as e: print "%s is not set, run select" % (e) raise SystemExit usage = "%(prog)s <FILENAME>" parser = argparse.ArgumentParser( usage=usage, formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("filen", metavar="filen", help="OBSERVATION FILENAME") args = parser.parse_args() venue = 'ops' filen = os.path.basename(args.filen) inst = parseVicarLabel.getInstrumentId(filen) site = parseVicarLabel.getSite(args.filen) drive = parseVicarLabel.getDrive(args.filen) loco = 'rover2orbital' pos = instruments.InstDic[inst][1] #position of instrument in rover frame x, y, z = places.getLocoSiteTranslation( venue, pos, site, drive, loco) #xyz translated to global frame print x, y, z return x, y, z
def InstPos(filen): '''Given a file, provides the xyz coordinate of the center of the observation''' inst = parseVicarLabel.getInstrumentId(filen) print "Instrument: ", inst if instruments.InstDic[inst][4] == 'range': pos = MastRangeCoord.sph2cart(filen) elif instruments.InstDic[inst][4] == 'flat': pos = MastRangeCoord.IntersectFlatPlane(filen) return pos
def WriteInFile(ivic): inst = str(parseVicarLabel.getInstrumentId(ivic)) print "Entering WriteInFile.MastInfile and printing instrument: ", inst print instruments.InstDic[inst] interType = instruments.InstDic[inst][2] fn = os.path.basename(ivic) base = os.path.splitext(fn)[0] #print vicar basename filename = 'p2xyz' + '_' + base + '.in' #create filename for p2xyz in_file parameter that tracks filename entry = "%s %s %s\n" % (interType, inst, ivic) #create text for in_file #print entry f = open(filename, 'w') # then write out the file f.write(entry) f.close() print "Leaving WriteInFile.MastInfile and returning filename: ", filename return filename
def ArmWriteInFile(filen, oDAT, oLBL): #lbl = os.path.splitext(filen)[0] + '.LBL' lbl = os.path.splitext(filen)[0] + '.LBL' print "Entering ArmWriteInFile.ArmInFile and running with lbl: ", lbl print "[ArmWriteInFile.ArmInFile] running with lbl: ", oLBL inst = str(parseVicarLabel.getInstrumentId(filen)) print "[ArmWriteInFile.ArmInFile] which inst: ", inst print "[ArmWriteInFile.ArmInFile] which dp (filen): ", filen #ARM = '/pipeline/arm_position/arm-position.py' print "[ArmWriteInFile.ArmInFile] what is ARM???: ", ARM #p1 = Popen((ARM,'--local-level',inst,oLBL),stdout=PIPE) #ARM = '/pipeline/arm_position/arm-position.py' p1 = Popen((ARM, inst, oLBL), stdout=PIPE) print "[ArmWriteInFile.ArmInFile] Running arm position p1: ", p1 p1.wait() n1 = p1.stdout.read() p1.stdout.close() """parse output of script to give C point and unit vector of the tool pointing as input for terrain intersection""" n1 = n1.replace(',', '') print "[ArmWriteInFile.ArmWriteInFile] here is n1: ", n1 pid = n1.split()[1] inst = n1.split()[1] pos_x = n1.split()[2] pos_y = n1.split()[3] pos_z = n1.split()[4] dir_x = n1.split()[5] dir_y = n1.split()[6] dir_z = n1.split()[7] """ Generate File and return the filename to be called""" fn = os.path.basename(filen) base = os.path.splitext(fn)[0] #print vicar basename print "[ArmWriteInFile.ArmInFile] printing base :", base filename = 'p2xyz' + '_' + base + '.in' #create filename for p2xyz in_file parameter that tracks filename print "[ArmWriteInFile.ArmInFile] created filename: ", filename entry = "UNIT ArmTool %s %s %s %s %s %s\n" % ( pos_x, pos_y, pos_z, dir_x, dir_y, dir_z) #create text for in_file f = open(filename, 'w') # then write out the file f.write(entry) f.close() print "[ArmWriteInFile.ArmInFile] Leaving function with base, entry, ", base, entry, " and returning filename: ", filename return filename
def allLoc(filen): print "Running allLoc" print "filen: ",filen loco = 'rover2orbital' print "loco: ",loco site = parseVicarLabel.getSite(filen) print "Site: ",site drive = parseVicarLabel.getDrive(filen) print "Drive: ",drive venue = "ops" inst = parseVicarLabel.getInstrumentId(filen) pos = instruments.InstDic[inst][1] print "Pos: ",pos sid = "NA" p2xyz_status = "0" x,y,z = places.getLocoSiteTranslation(venue,pos,site,drive,loco) #print str(len(xyz)) #print xyz return x,y,z,sid,p2xyz_status
def InstLocDB(filen): print "Entering InstLocDB.InstLoc.py" try: os.environ['R2LIB'] except KeyError as e: print "%s is not set, run select" % (e) raise SystemExit print "Here is the filen from " + __name__ + ".InstLoc.py: ", filen original = filen #print "Split: ", os.path.splitext(filen)[0] #print os.path.splitext(filen)[1] filen,oDAT,oLBL = getNewProduct(filen) inst = parseVicarLabel.getInstrumentId(filen) if inst == 'CHEMCAM_SOH' or inst == 'CHEMCAM_PARMS': SystemExit print "filename: ", filen print " creating array [" + __name__ + ".InstLoc.py]" print "instrument parsing of dictionary [" + __name__ + ".InstLoc.py]" #print "file: ",filen inst = parseVicarLabel.getInstrumentId(filen) #print "instrument: ", inst rover = parseVicarLabel.getSpacecraftId(filen) sol = parseVicarLabel.getPlanetDayNumber(filen) sclk = parseVicarLabel.getSclk(filen) oov = parseVicarLabel.getOriginOffsetVector(filen) q = parseVicarLabel.getOriginRotationQuaternion(filen) rmc = parseVicarLabel.getRoverMotionCounter(filen) az = parseVicarLabel.getAz(filen) el = parseVicarLabel.getEl(filen) #c = parseVicarLabel.getCameraCPoint(filen) #pId = parseVicarLabel.getProcessID(filen) ltst = parseVicarLabel.getLTST(filen) print "ltst :" + ltst lmst = parseVicarLabel.getLMST(filen) print "lmst :" + lmst # to do: add APP ID, Planetary Radius, Pointing Vector, ... # currently empty dictionaries seqID = parseVicarLabel.getSeqId(filen) apid = parseVicarLabel.getApId(filen) if parseVicarLabel.getApIdName(filen) == "McamLRecoveredProduct": return elif parseVicarLabel.getApIdName(filen) == "McamRRecoveredProduct": return elif parseVicarLabel.getApIdName(filen) == "RADSendData": return else: apidName = parseVicarLabel.getApIdName(filen) print rmc loc_x,loc_y,loc_z = places.getLocoRover('ops',rmc[0],rmc[1],'rover2orbital') inst = parseVicarLabel.getInstrumentId(filen) locType = instruments.InstDic[inst][1] print "Here is locType from " + __name__ + ".InstLoc.py: ",locType print "Here is filen from " + __name__ + ".InstLoc.py: ",filen print "Here is oLBL from " + __name__ + ".InstLoc.py: ",oLBL print "Here is oDAT from " + __name__ + ".InstLoc.py: ",oDAT x,y,z,sid,p2xyz_status = runLoco(locType,filen,oLBL,oDAT) stereo = parseVicarLabel.frameType(filen) LocArray['Stereo'] = stereo LocArray['Data_Product'] = original LocArray['Instrument'] = inst LocArray['Spacecraft_Clock(sec)'] = sclk LocArray['Rover_Global_Northing(m)'] = loc_x LocArray['Rover_Global_Easting(m)'] = loc_y LocArray['Rover_Global_Elevation(m)'] = loc_z LocArray['Global_Northing(m)'] = x LocArray['Global_Easting(m)'] = y LocArray['Global_Elevation(m)'] = z LocArray['LocType'] = locType LocArray['Rover_Motion_Counter'] = rmc LocArray['Site_Origin_Offset_Vector'] = oov LocArray['Quaternion'] = q LocArray['Instrument_Elevation(deg)'] = el LocArray['Instrument_Azimuth(deg)'] = az LocArray['Mission'] = rover LocArray['Sol_Number'] = sol #LocArray['Cpnt'] = c LocArray['Sequence_ID'] = seqID LocArray['Frame'] = 'orbital' LocArray['Local_Mean_Solar_Time'] = str(lmst) LocArray['Local_True_Solar_Time'] = str(ltst) LocArray['APID'] = apid LocArray['APID_Name'] = apidName LocArray['Surface_Intersection_DEM'] = sid LocArray['p2xyz_status_code'] = p2xyz_status #Print out the dictionary entry print "Here is dict.items(LocArray) from " + __name__ + ".InstLoc.py: ",dict.items(LocArray) print "Leaving " + __name__ + ".InstLoc.py returning: ", LocArray return LocArray