Re: Problem with ushort format in netCDF4

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 15 2012 - 16:42:10 MST

Wei-Chih,

Try the attached script.

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Feb 15, 2012, at 2:39 PM, wei chih chen wrote:

> Hi Wei,
> I know the problem is from my code which deal with double format. As a beginner of ncl, however, I don't know how to revise the code for ushort format. I did what you said, adding printVarSummary(ipr), and I found something like error message that "warning:Attempt to reference attribute (scale_factor) which is undefined" and "_FillValue : -999". I got all value -9999 in my .txt file. Could you please suggest me how to revise the code? The code is in the attachment, and I also uploaded the sample file "pr_tst.nc" in the ftp for your reference. Thank you.
>
>
> On Wed, Feb 15, 2012 at 11:08 AM, Wei Huang <huangwei@ucar.edu> wrote:
> Wei-Chih,
>
> Certainly your variable pr in ushort, but the code have converted it to float/double.
>
> So, what is exactly the problem, or do you have any error message.
>
> Can you add:
>
> printVarSummary(ipr)
>
> just below:
>
> printVarSummary(time1)
>
> to check the data type of "ipr".
>
> It now should be float or double.
>
> Thanks,
>
> Wei
>
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
>
> On Feb 15, 2012, at 8:16 AM, wei chih chen wrote:
>
>>
>> Dear user,
>> I have a problem extracting nc file with my NCL code. When I tried to use this code which my colleague gave me, I got the error like " unknow netCDF format". Moreover, I found my new nc file is written in ushort format but the NCL code is for double format (the code is in the attachment for your reference). The information of the nc file is as below. Could you please give me some advices how to revise the code to extract the data? Thank you.
>>
>> netcdf hadcm3.a1b.grid.conus.pr.1970.1979 {
>> dimensions:
>> lat = 222 ;
>> lon = 462 ;
>> time = UNLIMITED ; // (3650 currently)
>> variables:
>> double lat(lat) ;
>> lat:units = "degrees_north" ;
>> lat:long_name = "latitude" ;
>> double lon(lon) ;
>> lon:units = "degrees_east" ;
>> lon:long_name = "longitude" ;
>> ushort pr(time, lat, lon) ;
>> pr:scale_factor = 0.1 ;
>> pr:units = "mm" ;
>> pr:missing_value = 65535 ;
>> pr:long_name = "24h_cumulative_precipitation" ;
>> int time(time) ;
>> time:units = "days since 1959-12-31" ;
>> time:long_name = "time" ;
>>
>> // global attributes:
>> :history = "Created using the resources of the High Performance Computing Center at Texas Tech University Thu May 19 16:01:36 CDT 2011\n: converted double to NC_USHORT with scale factor of 10 for file at location /Volumes/Scratch/conus_grid/hadcm3/hadcm3.a1b.grid.conus.pr.1970.1979.nc" ;
>> :nco_openmp_thread_number = 1 ;
>> :source = "Downscaled using a statistical asynchronous regression technique after Stoner & Hayhoe from the U.K. Met Office HadCM3 historical abqzda (1960-1974) and abqzdd (1975-1990) and future acfxd (1991-2099) simulations. " ;
>> }
>> --
>> Best regards
>> Wei-Chih
>>
>> <Data_extract.ncl>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Best regards
> Wei-Chih
>
> <Data_extract.ncl>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 15 16:42:31 2012

This archive was generated by hypermail 2.1.8 : Thu Feb 23 2012 - 10:01:53 MST