;+ ; NAME: ; msu_weather ; ; ; PURPOSE: ; get weather station data from the Shaw lab weather station at MSU ; http://www.coe.montana.edu/ee/weather and parse it into a structure ; for analysis ; ; INPUTS: ; month: 1-12 month of the year ; year: year to get data ; ; ; OUTPUTS: ; structure array with n_elements = number of measurements and tags: ; DATE STRING '01/01/2007' ; TIME STRING '00:05' ; ADJ_PRESS_MB FLOAT 1021.00 ; ADJ_PRESS_INHG FLOAT 30.1501 ; ABS_PRESS_MB FLOAT 850.000 ; ABS_PRESS_INHG FLOAT 25.1005 ; TEMP_C FLOAT -7.42000 ; TEMP_F FLOAT 18.6440 ; REL_HUM FLOAT 81.7000 ; DEWPOINT_C FLOAT -10.0287 ; DEWPOINT_F FLOAT 13.9483 ; PART_PRESS_ATM FLOAT 0.00282139 ; NUM_DEN DOUBLE 7.7945600e+16 ; MASS_DEN FLOAT 2.58869 ; JD DOUBLE 2453916.5 ; ; where jd is julian day ; ; ; RESTRICTIONS: ; - extremely limited error checking so be careful ; - at some point the station added com calulated fields of num_den and ; such use for times after that ; - requires sswidl (solarsoft) ; ; EXAMPLE: ; IDL> ans = msu_weather(1, 2007) ; IDL> help, ans ; ANS STRUCT = -> <Anonymous> Array[8928] ; IDL> help, ans, /str ; ** Structure <865adcc>, 15 tags, length=84, data length=84, refs=1: ; DATE STRING '01/01/2007' ; TIME STRING '00:05' ; ADJ_PRESS_MB FLOAT 1021.00 ; ADJ_PRESS_INHG FLOAT 30.1501 ; ABS_PRESS_MB FLOAT 850.000 ; ABS_PRESS_INHG FLOAT 25.1005 ; TEMP_C FLOAT -7.42000 ; TEMP_F FLOAT 18.6440 ; REL_HUM FLOAT 81.7000 ; DEWPOINT_C FLOAT -10.0287 ; DEWPOINT_F FLOAT 13.9483 ; PART_PRESS_ATM FLOAT 0.00282139 ; NUM_DEN DOUBLE 7.7945600e+16 ; MASS_DEN FLOAT 2.58869 ; JD DOUBLE 2453916.5 ; ; ; ; MODIFICATION HISTORY: ; ; Fri Feb 23 09:46:03 2007, Brian Larsen ; ; written and tested ; ;- FUNCTION msu_weather, month, year month = string(month, format='(i02)') IF fix(year) LT 2000 THEN $ message, /ioerror, 'invalid year' year = string(year) ;stop url = 'http://www.coe.montana.edu/ee/weather/monthlyarchive' url += '/'+trim(month)+trim(year) ; add directory url += '/'+trim(month)+trim(year)+'.csv' ; add file name sock_list, url, dat ;; here is the format ;Date,Time,Sea-Level Adjusted Pressure(mb),Sea-Level Adjusted Pressure(inHg),Absolute Pressure(mb),Absolute Pressure(inHg),Temperature(C),Temperature(F),Relative Humidity(%),DewPoint(C),DewPoint(F),Partial Pressure(atmospheres),Number Density(molecules/cm),Mass Density(grams/cm) ;02/01/2007,00:05,1012,29.8844,841,24.8347,-6.675,19.985,86.4,-8.57752,16.5605,0.00316057,8.70715e+016,2.89178 data = create_struct('Date', '', $ 'Time', '', $ 'adj_press_mb', !values.f_nan, $ 'adj_press_inhg', !values.f_nan, $ 'abs_press_mb',!values.f_nan, $ 'abs_press_inhg',!values.f_nan, $ 'temp_c', !values.f_nan, $ 'temp_f', !values.f_nan, $ 'rel_hum', !values.f_nan, $ 'DewPoint_c',!values.f_nan, $ 'DewPoint_f',!values.f_nan, $ 'part_press_atm', !values.f_nan, $ 'num_den',!values.d_nan, $ 'mass_den',!values.f_nan, $ 'JD', !values.d_nan ) data = replicate(data, N_ELEMENTS(dat)-1) ; -1 for header ;; parse the data it is comma seperated FOR i=1l, N_ELEMENTS(dat)-1 DO BEGIN ; start at one to miss header parse = strsplit(dat[i], ',', /extract) FOR j=0l, N_ELEMENTS(parse)-1 DO BEGIN data[i-1].(j) = parse[j] ENDFOR tmp = anytim2jd(parse[1] + ' ' + parse[0]) data[i-1].jd = double(tmp.(0)) + tmp.(1) ENDFOR RETURN, data END
Disclaimer