Template option for files with Julian Day names

Zhenhao Bao z3bao at UWATERLOO.CA
Tue Jul 8 09:54:03 EDT 2008


Zhenhao Bao (PhD)
Dept. of Geography
University of Waterloo
200 university avenue west
Waterloo, Ontario, Canada n2l 3g1
z3bao at uwaterloo.ca


Quoting Arlindo da Silva <dasilva at ALUM.MIT.EDU>:

> On Thu, Jul 3, 2008 at 11:43 AM, Renu R. Joseph <rjoseph at atmos.umd.edu>
> wrote:
>
>>  Hello All,
>>
>> I need suggestions/solutions on dealing with the problem of opening files
>> with julian day included in the names.
>>
>> I have files that named with the following name format: m6s4_3hYYDDDHH.bin,
>> where YY represents the last two digits of the years (01 is 2001); DDD is
>> julian day; HH is the hour of the start of the measurement
>>
>> If grads allowed a julian day formats it could have been opened with
>> "m6s4_3h%y2%jd%h200.bin" in the dset file location as follows.
>>
>> dset ^m6s4_3h%y2%jd3%h2.bin
>> OPTIONS template
>> OPTIONS big_endian
>> OPTIONS yrev
>> UNDEF  -9999
>> TITLE  Precipitation estimates
>> XDEF 1440 LINEAR    0.125  0.25
>> YDEF 480 LINEAR  -59.875  0.25
>> ZDEF  01 LEVELS 1
>> TDEF 1 LINEAR  00z01jan2001 3 hr
>> VARS 1
>> per   1   99  (mm/hr)
>> ENDVARS
>>
>> Since I cannot do that, I know that one of the options is to use
>> DSET ^m6s4_3h%ch.bin
>> CHSUB   1  1 m6s4_3h0100100.bin
>> CHSUB   2  2 m6s4_3h0100100.bin
>> ..................................................
>> CHSUB  20448 20448 m6s4_3h0736521.bin
>> OPTIONS template
>>
>> but that includes so many lines. Is there a way around this, unless I
>> physically rename files to be consistent with grads format names?
>>
>
>
> You basically outlined your options. The best solution is to include julian
> day support in grads templating, something that is badly needed (I also ran
> into such files before).  In my case I had a good reason not to rename the
> files (other applications required the julian day type of name conventions),
> and sometimes making a copy of the files isn't an option (disk space
> considerations). Here are a couple of options which leave the original files
> alone:
>
> 1) Symlink each file to a grads friendly name in a separate directory, e.g.,
> grads/m6s4_2007-02-05_12z.bin. You should be able to do this with a
> relatively simple script.
>
> 2) If you know C, implement %j3 support in GrADS and contribute a patch. In
> GrADS both v1.9 and v2, look at this function in gautil.c:
>
> /* Given a file name template and a dt structure, fill in to get the file
> name */
> char *gafndt (char *fn, struct dt *dtim, struct dt *dtimi, float *vals,
> struct gachsub *pch1st, int t) {
>
>    Good Luck,
>
>       Arlindo
>
>
> --
> Arlindo da Silva
> dasilva at alum.mit.edu
>



More information about the gradsusr mailing list