Re: create time in netcdf variable

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Wed, 16 Jul 2008 23:21:23 -0400

Dear Dennis,
This worked. Thank you. Now I am trying this with multiple files
I'm having trouble.

How is NCL to 'know' that you want a multiple binary files with 8 time steps
in each file, say 30 days of September (at least where the first 9 days are
double digit? 01,02,03,04,...09
200609##hh
-Erik

On 7/16/08 2:21 PM, "Dennis Shea" <shea_at_ucar.edu> wrote:

> As Jamie has stated and the output print statements show,
> you are overwriting the information each loop iteration.
>
> How is NCL to 'know' that you want a file with 8 time steps on it?
>
> [a]
> You could create a single netCDF file for each time and use (say) ncrcat
> to concatenate the files.
>
> [b]
> You can preallocate arrays and then after the loop write to the file once.
> Something like:
>
> ntim = 8
> nlat = 480
> mlon = 1440
>
> yyyymmdd = year*10000 + month*100 + day
> time = yyyymmdd*100 + ispan(0,21,3)
> time!0 = "time"
> time_at_units = "yyyymmddhh"
> time&time = time
> print(time)
>
> CMORPH = new ( (/ntim,nlat,mlon/), "float")
> pc_combined_MW = CMORPH
>
> fName = "./20060901_3hr-025deg_cpc+comb"
>
> do i = 0, 14,2
> pc_combined_MW(i/2,:,:) =
> fbindirread(fName,i,(/ntim,nlat,mlon/),"float")
> CMORPH(i/2,:,:) = fbindirread(fName, i+1,(/ntim,nlat,mlon/),"float")
> end do
>
> CMORPH!0 = "time"
> CMORPH!1 = "lat"
> CMORPH!2 = "lon"
> CMORPH&time = time
> CMORPH&lat = lat
> CMORPH&lon = lon
> CMORPH_at_long_name = "CMORPH"
> CMORPH_at_units = "mm/hr"
>
> ; same for pc_combined_MW
>
>
>
> a = addfile("sample.nc","c") ; write netCDF file
> a_at_title = "1 day of daily CMORPH precipitation data"
> a_at_source =
> "ftp://ftp.cpc.ncep.noaa.gov/precip/global_CMORPH/3-hourly_025deg"
> filedimdef(a,"time",-1,True) ; make time an UNLIMITED
>
> a->CMORPH = CMORPH
> a->COMB_MW = pc_combined_MW
> end
>
>
>
>
>
>
>
>
> Erik Noble wrote:
>> Hi.
>> You suggest eliminating the do loop, correct?
>> -Erik
>>
>> On Wed, Jul 16, 2008 at 12:20 PM, Jamie Scott <James.D.Scott_at_noaa.gov> wrote:
>>
>>> Eric,
>>> I think the problem is that the 2 variables you are writing to the netcdf
>>> file
>>> only contain one time step. Even though you are looping through time
>>> and writing 8 times, I think you are just overwriting the 1st time step in
>>> the
>>> netcdf file each time.
>>> Try making the variables you write (cpc_combined_mw, cmorph and time)
>>> such that they contain all 8 time steps and write them only once.
>>>
>>> Jamie Scott
>>>
>>> NOAA/ESRL/PSD
>>>
>>> james.d.scott_at_noaa.gov
>>>
>>> On Jul 16, 2008, at 9:58 AM, ncl-talk-request_at_ucar.edu wrote:
>>>
>>> May I have some help? This is an update my earlier request for help
>>> with getting time displayed in my netcdf file. I updated my code fromearlie
>>> till getting incorrect time. When I do
>>> "ncdump -h" on the my output netcdf file, I don't get the proper time
>>> that should reflect 3-hourly intervals for 1 day.
>>> (It says time = UNLIMITED ; // (1 currently). it should be time =
>>> UNLIMITED ; // (8 currently)).
>>> I'm reading in a binary file that I'm told is composed of 16 direct
>>> access binary ("big_endian") records, which are 2 variables at
>>> 3-hourly ntervals for 1 day, basically 8 pairs.
>>>
>>> I searched throughout previous posts about time coordinates before
>>> posting this question ncl-talk. Its not clear whether i need to resort
>>> to making up this variable (i.e. specifically make a variable time =
>>> year*10000 + month*100 + day...etc) or if Its something even more
>>> simple that I am overlooking.
>>>
>>> Could I have please have some advice on how to fix this? I have my
>>> screen readouts and ncl code below.
>>> -Erik
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk_at_ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 16 2008 - 21:21:23 MDT

This archive was generated by hypermail 2.2.0 : Fri Jul 18 2008 - 08:51:52 MDT