Changeset 396
- Timestamp:
- 04/08/09 18:14:31 (15 years ago)
- Location:
- trunk/SRC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Calendar/julday.pro
r371 r396 257 257 L_YEAR = LONG(YEAR) 258 258 ; 259 tochange = where(L_MONTH LT 0) 260 IF tochange[0] NE -1 THEN BEGIN 261 L_YEAR[tochange] = L_YEAR[tochange]+L_MONTH[tochange]/12-1 262 L_MONTH[tochange] = 12 + L_MONTH[tochange] MOD 12 263 ENDIF 264 ; 265 tochange = where(L_MONTH GT 12) 266 IF tochange[0] NE -1 THEN BEGIN 267 L_YEAR[tochange] = L_YEAR[tochange]+L_MONTH[tochange]/12 268 L_MONTH[tochange] = L_MONTH[tochange] MOD 12 259 tochange = where(L_MONTH LE 0) 260 IF tochange[0] NE -1 THEN BEGIN 261 tmp = L_MONTH[tochange] - 12L 262 L_YEAR[tochange] = L_YEAR[tochange] + tmp/12L 263 L_MONTH[tochange] = (temporary(tmp) MOD 12L) + 12L 264 ENDIF 265 ; 266 tochange = where(L_MONTH GT 12L) 267 IF tochange[0] NE -1 THEN BEGIN 268 tmp = L_MONTH[tochange] - 1L 269 L_YEAR[tochange] = L_YEAR[tochange] + tmp/12L 270 L_MONTH[tochange] = (temporary(tmp) MOD 12L) + 1L 269 271 ENDIF 270 272 ; -
trunk/SRC/ReadWrite/ncdf_getatt.pro
r391 r396 102 102 'units':BEGIN 103 103 ncdf_attget, cdfid, varid, attname, tmp 104 units = str trim(tmp, 2)104 units = strcompress(strtrim(tmp, 2)) 105 105 END 106 106 'calendar':BEGIN -
trunk/SRC/ReadWrite/ncdf_gettime.pro
r391 r396 61 61 ; 62 62 IF n_elements(cdfid) EQ 0 THEN BEGIN 63 cdfid = ncdf_open(isafile(filename, title = 'which file must be open by ncdf_gettime?', IODIRECTORY =iodir, _extra = ex))63 cdfid = ncdf_open(isafile(filename, title = 'which file must be open by ncdf_gettime?', IODIRECTORY = iodir, _extra = ex)) 64 64 tobeclosed = 1 65 65 ENDIF … … 149 149 ;---------------------------------------------------- 150 150 ; 151 value = strlowcase(value) 152 IF value NE 'true julian day' THEN BEGIN 151 153 ; time_counter:units = "seconds since 0001-01-01 00:00:00" ; 152 154 ; time_counter:units = "hours since 0001-01-01 00:00:00" ; … … 156 158 ; 157 159 ; we decript the "units" attribute to find the time origin 158 value = strtrim(strcompress(string(value)), 2) 159 words = str_sep(value, ' ') 160 units = words[0] 161 units = strlowcase(units) 162 IF strpos(units, 's', strlen(units)-1) NE -1 THEN units = strmid(units, 0, strlen(units)-1) 163 IF strpos(units, 'julian_') NE -1 THEN units = strmid(units, 7) 164 IF units NE 'second' AND units NE 'hour' AND units NE 'day' $ 165 AND units NE 'month' AND units NE 'year' THEN BEGIN 166 CASE caller OF 167 'read_ncdf':err = 'time units does not start with seconds/hours/days/months/years !C Use the TIMESTEP keyword' 168 'scanfile':err = 'time units does not start with seconds/hours/days/months/years !C we create a fake calendar ...' 169 ENDCASE 170 IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 171 return, -jpt 172 ENDIF 173 IF stregex(value, '[^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*', /boolean) EQ 0 THEN BEGIN 174 CASE caller OF 175 'read_ncdf':err = 'attribute units of time has not the good format: [^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*!C Use the TIMESTEP keyword' 176 'scanfile':err = 'attribute units of time has not the good format: [^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*!C we create a fake calendar ...' 177 ENDCASE 178 IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 179 return, -jpt 180 ENDIF 181 start = str_sep(words[2], '-') 160 words = str_sep(value, ' ') 161 units = words[0] 162 IF strpos(units, 's', strlen(units)-1) NE -1 THEN units = strmid(units, 0, strlen(units)-1) 163 IF strpos(units, 'julian_') NE -1 THEN units = strmid(units, 7) 164 IF units NE 'second' AND units NE 'hour' AND units NE 'day' $ 165 AND units NE 'month' AND units NE 'year' THEN BEGIN 166 CASE caller OF 167 'read_ncdf':err = 'time units does not start with seconds/hours/days/months/years !C Use the TIMESTEP keyword' 168 'scanfile':err = 'time units does not start with seconds/hours/days/months/years !C we create a fake calendar ...' 169 ENDCASE 170 IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 171 return, -jpt 172 ENDIF 173 IF stregex(value, '[^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*', /boolean) EQ 0 THEN BEGIN 174 CASE caller OF 175 'read_ncdf':err = 'attribute units of time has not the good format: [^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*!C Use the TIMESTEP keyword' 176 'scanfile':err = 'attribute units of time has not the good format: [^ ]* since ([0-9]){1,4}-([0-9]){1,2}-([0-9]){1,2}.*!C we create a fake calendar ...' 177 ENDCASE 178 IF keyword_set(tobeclosed) THEN ncdf_close, cdfid 179 return, -jpt 180 ENDIF 181 start = str_sep(words[2], '-') 182 ENDIF ELSE units = value 182 183 ;---------------------------------------------------- 183 184 ; compute time axis … … 185 186 ncdf_varget, cdfid, timeid, time 186 187 time = double(time) 187 case units of 188 case units OF 189 'true julian day': 188 190 'second':time = julday(start[1], start[2], start[0], 0, 0, 0)+time/86400.d 189 191 'hour':time = julday(start[1], start[2], start[0], 0, 0, 0)+time/24.d … … 191 193 'month':BEGIN 192 194 if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 193 time = julday(start[1], start[2], start[0])+round(time*30) $ 194 ELSE for t = 0, n_elements(time)-1 DO $ 195 time[t] = julday(start[1]+time[t], start[2], start[0]) 195 time = julday(start[1], start[2], start[0], 0, 0, 0) + round(time*30) $ 196 ELSE time = julday(start[1]+fix(time), replicate(start[2], jpt), replicate(start[0], jpt), 0, 0, 0) 196 197 END 197 198 'year':BEGIN 198 199 if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 199 time = julday(start[1], start[2], start[0])+round(time*365) $ 200 ELSE for t = 0, n_elements(time)-1 do $ 201 time[t] = julday(start[1], start[2], start[0]+time[t]) 200 time = julday(start[1], start[2], start[0], 0, 0, 0) + round(time*365) $ 201 ELSE time = julday(replicate(start[1], jpt), replicate(start[2], jpt), start[0]+fix(time), 0, 0, 0) 202 202 END 203 203 ENDCASE
Note: See TracChangeset
for help on using the changeset viewer.