[gradsusr] Creating a Binary File in Grads

Kishore Ragi kishoreragi at gmail.com
Sat Jan 24 22:04:46 EST 2015


If you follow my suggestions carefully, you can get whatt you wanted.

Yes, I understand that you have .dat file with ctl. But, by the previous
suggestions, you can convert those .dat and ctl files to netcdf. Then you
can merge them as a combined netcdf. Handling of netcdf files is much
simpler than any other climate data files, atleast for me.

You just copy paste those commands that I have posted in the previous
email, if you already installed CDO in your machine.

But, if your goal is only to write grads script, other grads users may help
you.

Good luck !

Regards,

Kishore



On Sun, Jan 25, 2015 at 2:59 AM, Valeria Benson-Lira <vbensonl at asu.edu>
wrote:

> Hi Kishore,
>
> Thank you for your suggestions. The problem is that I need to have the
> script working for grads.
> For instance, my precipitation control files open a .dat file, they are
> not a netcdf.
> In this case, I want to create a binary file (.dat) which has all the
> precipitation values recorded in the 4 different files.
> No calculations are needed.
>
> Any suggestions?
>
> Thanks,
> Valeria
>
>
>
> On Fri, Jan 23, 2015 at 11:11 PM, Kishore Ragi <kishoreragi at gmail.com>
> wrote:
>
>> After getting this, if you still want only binary files, please let me
>> know. there are couple of options to make nc file to .dat file, even with
>> grads.
>>
>> On Sat, Jan 24, 2015 at 11:37 AM, Kishore Ragi <kishoreragi at gmail.com>
>> wrote:
>>
>>>
>>>
>>> *Hi Valeria Benson-Lira,*
>>> If you don't have problem working with nc files, I will give you other
>>> option to achieve your task.
>>>
>>> First, you make your ctl file into netcdf files as below
>>>
>>> cdo -f nc import_binary ENCB1_precip_apr2008.ctl precip.april.nc
>>> cdo -f nc import_binary ENCB1_precip_may2008.ct precip.may.nc
>>> cdo -f nc import_binary ENCB1_precip_jun2008.ctl precip.june.nc
>>> cdo -f nc import_binary ENCB1_precip_july2008.ctl precip.july.nc
>>>
>>> now merge them all in a single file like below
>>>
>>> cdo mergetime precip.april.nc precip.may.nc precip.june.nc
>>> precip.july.nc precip.AMJJ.nc
>>>
>>> Though, I did not help with grads, hope this helps.
>>>
>>> Cheers,
>>>
>>> Kishore
>>>
>>> On Sat, Jan 24, 2015 at 11:11 AM, Valeria Benson-Lira <vbensonl at asu.edu>
>>> wrote:
>>>
>>>> Dear Grads users,
>>>>
>>>> Can someone please help me with my script? I am trying to write a
>>>> binary file that contains all the values recorded in four different control
>>>> files. My new binary file will have the hourly precipitation records from
>>>> April through July. So far, the script works for the first month but not
>>>> for the following months.
>>>>
>>>> This is the script:
>>>>
>>>>
>>>> 'reinit'
>>>>
>>>> 'open ENCB1_precip_apr2008.ctl'
>>>>
>>>> 'open ENCB1_precip_may2008.ct'
>>>>
>>>> 'open ENCB1_precip_jun2008.ctl'
>>>>
>>>> 'open ENCB1_precip_july2008.ctl'
>>>>
>>>>
>>>> 'set gxout fwrite'
>>>>
>>>> 'set fwrite ENCB1_AMJJ_precip.dat '
>>>>
>>>>
>>>> *****Write April data First.
>>>>
>>>> *****Recall that April has 720 hours (30 days)
>>>>
>>>> *index*_t = 1
>>>>
>>>> while(*index*_t<=720)
>>>>
>>>>   'set t '*index*_t
>>>>
>>>>   say *index*_t
>>>>
>>>>   'd precip.1 '
>>>>
>>>>   *index*_t = *index*_t + 1
>>>>
>>>> endwhile
>>>>
>>>>
>>>> *****Write May data Next.
>>>>
>>>> *****Recall that May has 744 hours (31 days)
>>>>
>>>> *index*_t = 1
>>>>
>>>> while(*index*_t<=744)
>>>>
>>>>   'set t '*index*_t
>>>>
>>>>   say *index*_t
>>>>
>>>>   'd precip.2 '
>>>>
>>>>   *index*_t = *index*_t + 1
>>>>
>>>> endwhile
>>>>
>>>>
>>>> *****Write June data Next.
>>>>
>>>> *****Recall that June has 720 hours (30 days)
>>>>
>>>> *index*_t = 1
>>>>
>>>> while(*index*_t<=720)
>>>>
>>>>   'set t '*index*_t
>>>>
>>>>   say *index*_t
>>>>
>>>>   'd precip.3 '
>>>>
>>>>   *index*_t = *index*_t + 1
>>>>
>>>> endwhile
>>>>
>>>>
>>>> *****Write July data Next.
>>>>
>>>> *****Recall that July has 744 hours (31 days)
>>>>
>>>> *index*_t = 1
>>>>
>>>> while(*index*_t<=744)
>>>>
>>>>   'set t '*index*_t
>>>>
>>>>   say *index*_t
>>>>
>>>>   'd precip.4 '
>>>>
>>>>   *index*_t = *index*_t + 1
>>>>
>>>> endwhile
>>>>
>>>>
>>>> *************************
>>>>
>>>> 'disable fwrite'
>>>>
>>>> *************************
>>>>
>>>> *****Always reinitialize when finished,
>>>>
>>>> *****to avoid mistakingly writing extraneous data
>>>>
>>>> 'reinit'
>>>>
>>>>
>>>> Do you have a suggestion of how I can fix it?
>>>>
>>>> Thanks,
>>>>
>>>> *Valeria Benson-Lira*
>>>> *Graduate Teaching Assistant, Geography M.A.*
>>>> *e-mail: vbensonl at asu.edu <vbensonl at asu.edu>*
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> gradsusr mailing list
>>>> gradsusr at gradsusr.org
>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150125/0e31fb31/attachment.html 


More information about the gradsusr mailing list