# [ncl-talk] Please correct me: Extracting data of USA

Mary Haley haley at ucar.edu
Thu Nov 6 17:55:17 MST 2014

You can tell from your "print(c)" command what area the "c" variable covers:

Variable: c
Type: float
Total Size: 544320 bytes
136080 values
Number of Dimensions: 3
Dimensions and sizes:   [time | 360] x [lat | 14] x [lon | 27]
Coordinates:
time: [15.5..10941.5]
lat: [25.18098640441895..49.42915344238281]
lon: [236.25.. 285]

Note the lat array goes from 25.18 to 45.43, and the lon array from 236.25
to 285. This is in accordance with the range you selected via:

c =a->tasmax(:,{25:50},{235:285})

I'm not sure what you mean by "the middle coordinates of each grid cell".
Do you mean the midpoint of the lat/lon coordinate arrays? This would be a
simple subtraction and divide by 2:

nlon = dimsizes(c&lon)

lon_mid = c&lon(0:nlon-2) + (c&lon(1:) - c&lon(0:nlon-2))/2.

--Mary

On Thu, Nov 6, 2014 at 7:47 AM, amit timilsina <
timilsinaamit87 at huskers.unl.edu> wrote:

>
> I have used the following commands to extract data of USA (print c, in
> this case). Please suggest me whether I am wrong or right. If print(c)
> covers the whole USA, I tried to write extracted file with command and
> created fout.nc file. Is this is proper way to save my work? Moreover,
> Can we get the middle co-ordinates of each grid cell?
> Thanks in advance
>
> Commands:
> >ncl 3> a =
> >ncl 4> b =a->tasmax
> >ncl 5> c =a->tasmax(:,{25:50},{235:285})
> >ncl 6> print(c)
> >ncl>7>d = c
>  >ncl>ncdf = addfile("fout.nc"."c")
> >ncl>filedimdef(ncdf,"time",-1,True)
> >ncl>ncdf->c = d
>
>
> Output of print(b)
>
> Variable: b
> Type: float
> Total Size: 26542080 bytes
>             6635520 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 360] x [lat | 96] x [lon | 192]
> Coordinates:
>             time: [15.5..10941.5]
>             lat: [-88.57216644287109..88.57216644287109]
>             lon: [   0..358.125]
>
>
> Output of print(c)
>
> Variable: c
> Type: float
> Total Size: 544320 bytes
>             136080 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 360] x [lat | 14] x [lon | 27]
> Coordinates:
>             time: [15.5..10941.5]
>             lat: [25.18098640441895..49.42915344238281]
>             lon: [236.25.. 285]
> Number Of Attributes: 11
>   standard_name :       air_temperature
>   long_name :   Daily Maximum Near-Surface Air Temperature
>   comment :     monthly mean of the daily-maximum near-surface air
> temperature.
>   units :       K
>   cell_methods :        time: maximum within days time: mean over days
>   cell_measures :       area: areacella
>   history :     2011-11-09T08:48:40Z altered by CMOR: Treated scalar
> dimension: 'height'.
>   coordinates : height
>   missing_value :       1e+20
>   _FillValue :  1e+20
>   associated_files :    baseURL:
> http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile:
> (0,0,0) 291.8939
> (0,0,1) 291.681
> (0,0,2) 292.1985
> (0,0,3) 293.3919
> (0,0,4) 294.4564
> (0,0,5) 295.4993
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141106/61fc05bc/attachment.html