;+ ; ; AUTHOR: ; Lon Riesberg ; ; FILENAME: ; prep_pan.pro ; ; DATE: ; 04/17/2007 ; ; PURPOSE: returns a list of metadata needed for the PDC after querying ; the AIM_CIPS_SCIENCE db ; ; INPUT PARAMETERS: ; filename - file to create metadata for ; ; OUTPUT PARAMETERS: ; ; RETURN VALUE: argument list used by send_pan.pl to create and send xml ; formatted email with metadata ; ; EXAMPLE USAGE: ; pan_args = prep_cips_pan(full_path_to_file, product_type, start_time, end_time ; ; http://lasp.colorado.edu/aim/cips/data/repository/v4.20/ ; ;------------------------------------------------------------------------------ Function Callback_neturl, StatusInfo, ProgressInfo, CallbackData print, StatusInfo print, ProgressInfo[0], ProgressInfo[1], ProgressInfo[2], ProgressInfo[3], ProgressInfo[4] result = STRPOS( StatusInfo, "Error" ) ; print, "Result = ", result IF result GT 0 THEN return, 0 return, 1 END function prep_pan, filename, product_type, start_time, end_time, data_directory=data_directory, url=url base_filename = file_basename(filename) version = get_version_from_filename( filename ) ; Example URL ; http://lasp.colorado.edu/aim/cips/data/repository/north_2007/level_2/cips_sci_2_orbit_00734_2007-165_v04.20_r05_alb.png ins = 'CIPS' act = 'ADD' src = 'LASP' mission = 'AIM' IF NOT KEYWORD_SET( URL ) THEN BEGIN url = 'http://lasp.colorado.edu/aim/cips/data/repository/' + data_directory + '/' + base_filename ENDIF title = 'CIPS ' + product_type desc = " " dp_version = string(version, format='(F3.1)') pf_version = string(1.0, format='(F3.1)') sw_version = string(version, format='(F3.1)') calib_version = string(!REVISION_2, format='(F3.1)') dp_type = product_type fileinfo = file_info(data_directory+'/'+filename) comments = "File size: " + strtrim(string(fileinfo.size/1E6, format='(F6.1)'), 1) + ' MB' lat = 'NA' lon = 'NA' alt = 'TBD' ; TODO: grab average altitude over orbit from TLE's.... alternatively, query for all the ; corresponding 1A images and average sc_altitude history = " " ; start_time (e.g. yyyydoyhhmmss) start_time_la = gps2la(start_time/1E6) year = (strsplit(start_time_la, '/', /extract)) doy = (strsplit(year[1], '-', /extract)) hms = (strsplit(doy[1], ':', /extract)) start_time_pdc_format = year[0] + doy[0] + hms[0] + hms[1] + hms[2] ; end_time (e.g. yyyydoyhhmmss) end_time_la = gps2la(end_time/1E6) year = (strsplit(end_time_la, '/', /extract)) doy = (strsplit(year[1], '-', /extract)) hms = (strsplit(doy[1], ':', /extract)) end_time_pdc_format = year[0] + doy[0] + hms[0] + hms[1] + hms[2] ; TODO: should probably query the Files table for the productionDateTime field and format as needed ; generation date (e.g. yyyydoyhhmmss) curr_time=systime(/seconds, /julian, /utc) la_time = jd2la(curr_time) year = (strsplit(la_time, '/', /extract)) doy = (strsplit(year[1], '-', /extract)) hms = (strsplit(doy[1], ':', /extract)) gen_date = year[0] + doy[0] + hms[0] + hms[1] + hms[2] args = [ins, act, base_filename, title, src, mission, product_type, url, dp_version, pf_version, sw_version, dp_type, $ calib_version, desc, gen_date, history, start_time_pdc_format, end_time_pdc_format, lat, lon, alt, comments] arg_list = '' for i=0, (n_elements(args)-1) do begin arg_list = arg_list + "'" + args[i] + "' " endfor return, ptr_new(arg_list) ; Test URL to make sure file really exists ; Create a new url object oUrl = OBJ_NEW('IDLnetUrl') ; This is an ftp transaction oUrl->SetProperty, URL_SCHEME = 'http' ; Use the ftp server string entered in the text box oUrl->SetProperty, URL_HOSTNAME = "lasp.colorado.edu" ; name of remote server directory url_path = 'aim/cips/data/repository/v4.20/' + data_directory + '/' + base_filename oUrl->SetProperty, URL_PATH = url_path ; Set the appropriate username and password oUrl->SetProperty, URL_USERNAME = '' oUrl->SetProperty, URL_PASSWORD = '' oUrl->SetProperty, CALLBACK_FUNCTION = 'Callback_neturl' ; The call to get needs to be caught or exicution will halt catch, error_status if error_status ne 0 then begin catch, /cancel handle_error, error_status retrievedFilePath = "" GOTO, SKIPIT endif ; Copy the selected remote file into the specified local directory retrievedFilePath = oUrl->Get(FILENAME="/tmp/"+base_filename ) SKIPIT: IF retrievedFilePath NE "/tmp/"+base_filename THEN BEGIN PRINT, base_filename + " not found on website " OPENW, UNIT, "/home/aimsds/missing_data_lon.txt", /APPEND, /GET_LUN PRINTF, UNIT, base_filename CLOSE, UNIT FREE_LUN, UNIT return, ptr_new() ENDIF CATCH, /CANCEL ; Close the connection to the remote FTP server, and destroy the object oUrl->CloseConnections OBJ_DESTROY, oUrl FILE_DELETE, "/tmp/"+base_filename return, ptr_new(arg_list) end