def getDate(f_obj): return GOSAT_L2.getDate(f_obj)
def procCommands(c): global FILE_SYS global CURR_DIR global CURR_FILE global BUFFER if c == 0: getRoot() return if c == 1: #set current directory checkFileSys() dir = getDirectory() if(dir == None): print("Directory does not exist") else: CURR_DIR = dir return if c == 2: #Print files in current directory if(FILE_SYS == None): print("No file system has been created yet") return if(CURR_DIR != None): for f in CURR_DIR.files: print(f.name) else: print("Current directory is not set") return if c == 3: #Set current file f = getFile() if(f != None): CURR_FILE = h5py.File(f.path,"r") save(CURR_FILE) print(f.name + " has been opened and set as CURR_FILE") else: print("File does not exist") return if c == 4: #display groups if(CURR_FILE == None): print("No file has been set") else: for group in CURR_FILE: print(group) return if c == 5: #Display datasets checkFileSys() if(CURR_FILE == None): print("No file has been set") return name = input("Enter name of group to show names of datasets") d = None try: d = CURR_FILE[name] except StandardError: print("Invalid Group Name") return for data in d: print(data) return if c == 6: #Display BUFFER print("Contents of BUFFER") for thing in BUFFER: print(thing) if c == 7: #print current directory checkFileSys() if(CURR_DIR != None): CURR_DIR.print_d() else: print("Current directory not set") if c == 8: #Flush Buffer BUFFER[:] = [] if c == 9: #place files in buffer given latitudes and longetudes lat_ = input("Enter the latitude you are looking for") long_ = input("Enter the longitude longitude you are looking for") #optional date date = str(input("Enter the date as yymmdd(optional-enter 'n' otherwise)")) if(date == "n"): date = "" if(CURR_DIR == None): print("current directory has not been set") return else: FILE_OBJS = 0 FILE_NAME = 1 FILE_COORDS = 2 FILE_CO2_LEVELS = 3 #find the files with the correct coords (directory , longitude, latitude, optional date) files = GOSAT_L2.findFilesByCoords(CURR_DIR, long_, lat_,date) #print file names print("The following files will be placed in the buffer: ") for i in range(len(files[FILE_NAME])): print(files[FILE_NAME][i]) save(files[FILE_OBJS][i]) save(files[FILE_COORDS]) #print points that fall in the coordinate range print("Number of points that fall in the region: " + str(len(files[FILE_COORDS])) ) #write to file? ans = input("Write coords to file?") if(ans == "y"): form = format(formatConverter.getValidFormat(),files[FILE_COORDS] ,files[FILE_CO2_LEVELS]) nam = input("Enter name of file: ") saveCoordsToTextFile(nam, form) else: print("Not writing coords to file....") #write file names to file? ans = input("Write to file names that fall into the given bounding?") if(ans == "y"): nam = input("Enter name of file: ") saveToTextFile(files[FILE_NAME]) else: print("Not writing file names to file...") if c == 10: #print data set if CURR_FILE == None: print("Current file not set") return group_n = input("Enter the Group name of this file") data_n = input("Enter the data set name of this group") data_set = None try: data_set = CURR_FILE[group_n][data_n] except StandardError: print("Invalid Group Name") return for thing in data_set: print(thing) print("The following data set is " + str(len(data_set)) + str("rows long") + str(" and ") + str(len(data_set[0])) + str(" wide.")) print("By " + str(len(data_set[0][0][0])) ) if c == 11: #return files that are within a certain km^2 with long,lat at the center pass if c == 12: #Output to file pass if c == 13: #Display long average of file if CURR_FILE == None: print("Current file not set") return print("Average longitude is : " + str(GOSAT_L2.getLongAvg(CURR_FILE))) if c == 14: #display lat. average of file if CURR_FILE == None: print("Current file not set") return print("Average latitude is : " + str(GOSAT_L2.getLatAvg(CURR_FILE))) if c == 15: #display date of current file if(CURR_FILE != None): print(getDate(CURR_FILE)) else: print("Current File not set") if c == EXIT: print("BYE") sys.exit(0)