Re: Coordinate scripting for

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 12 Dec 2007 09:27:10 -0700

Since your "lat" [XLAT] and "lon" [XLONG] variables are two
dimensional, they can not be used as coordinate variables. Hence,
   
            v_plane&lat = lat

is illegal. Please remove from you code. The & can only be used for
netCDF type coordinate variables. As mentioned several times before
in these threads, netCDF coordinate variables can only be 1D
monotonic {in/de}creasing arrays.

The {...} syntax is for coordinate variables only. The assignment statement

            V = v_plane({lat|37:55},{lon|11:89})

uses {...} so NCL thinks you are using coordinate variables.

Standard subscripting would be

             V = v_plane(lat|37:55,lon|11:89)

In fact, if the variable is: v_plane(lat,lon) then you could use

            V = v_plane(37:55,11:89)

As noted in NCL documentation, named dimensions are used when
you are reordering the data. You are not reordering.

If you plan on plotting V the you should do the following

             V_at_lat2d = lat(37:55,11:89)
             V_at_lon2d = lon(37:55,11:89)

Better programming practices would suggest using variables for the
subscripts.
It would make future changes less error prone

            js = 37
            je = 55
            is = 11
            ie = 89
            V = v_plane(js:je,is:ie)
            V_at_lat2d = lat(js:je,is:ie)
            V_at_lop2d = lon(js:je,is:ie)

 

             

Erik Noble wrote:
> Dear Dr. Shea,
> According to your referenced pages and recommendation for "standard
> subscripting," the part of my code should read:
> v_plane = wrf_user_intrp3d( v,p,"h",pressure,0.,False)
> printVarSummary(v_plane)
> v_plane!0 = "lat"
> v_plane!1 = "lon"
> v_plane&lat = lat ; line 39
> v_plane&lon = lon
> V = v_plane({lat|37:55},{lon|11:89})
>
> Now i have another error:
> fatal:Variable (lat) is undefined
> fatal:Execute: Error occurred at or near line 39 in file NCL_ascii_V700.ncl
>
> Why?
> -Erik
>
> On Dec 11, 2007 3:13 PM, Dennis Shea <shea_at_ucar.edu> wrote:
>
>> I am not sure what to say any more.
>>
>> [1] In my earlier post [Response 1b] I said that by netCDF
>> rule **coordinate variables must be one dimensional**
>>
>> [2] The results of the following are **two dimensional**
>>
>> if (rank.eq.3) then
>> lat = a->XLAT(0,:,:) ; opt could bt "nt" f->XLAT(opt,:,:)
>> lon = a->XLONG(0,:,:)
>> else
>> if (rank.eq.2) then
>> lat = a->XLAT
>> lon = a->XLONG
>> [snip]
>>
>> ===
>> [3] To repeat earlier responses: coordinate subscripting
>> can not be used for your data. *Only
>> standard subscripting can be used.*
>>
>> ===================================================
>>
>>
>>
>> Erik Noble wrote:
>>
>>> Attached code.
>>> On Dec 11, 2007 2:26 PM, Erik Noble <enoble_at_giss.nasa.gov> wrote:
>>>
>>>
>>>> Hi Soyoung Ha.
>>>> Thank you.
>>>> This helps.
>>>>
>>>> Now I have a different error (Below):
>>>> fatal:Coordinate variables must have one dimension only
>>>> fatal:No coordinate variable exists for dimension (lat) in variable (v_plane)
>>>> Bus error
>>>>
>>>> This is all WRF data. My inquiry is related to the earlier inquiry
>>>> addressing interpolating WRF pressure-level data.
>>>> I interpolated pressure level data using the WRF_user_interp3d
>>>> command. The result of using the WRF_NCL code presents the
>>>> pressure-level data in 109 rows and 139 columns; It used to have
>>>> coordinates before using the ncl WRF_user_interp3d command.
>>>> Variable: v_plane
>>>> Type: float
>>>> Total Size: 60604 bytes
>>>> Number of Dimensions: 2
>>>> Dimensions and sizes: [109] x [139]
>>>> Coordinates:
>>>>
>>>> I am simply trying to extract a smaller subset from a larger set of
>>>> data. Since ncl WRF_user_interp3d command took away coordinates, I
>>>> just want data in between rows 37-55 and columns 11-89.
>>>>
>>>> My code keeps getting longer and longer. Yet with these errors, I am
>>>> having to resort to converting the large [109] x [139] files to ascii
>>>> and creating the the [37-55] x [11-89] subsets through Microsoft
>>>> Excel, which takes a while.
>>>> Any suggestions here?
>>>> -Erik
>>>>
>>>>
>>>> On Dec 11, 2007 1:57 PM, Soyoung Ha <syha_at_ucar.edu> wrote:
>>>>
>>>>
>>>>>> Thank you Dr. Shea,
>>>>>> M variable has 109 rows and 139 columns.
>>>>>> Does that change things?
>>>>>>
>>>>>> i tried the suggestions from the two pages you gave below by adding
>>>>>>
>>>>>> v_plane = wrf_user_intrp3d( v,p,"h",pressure,0.,False)
>>>>>> printVarSummary(v_plane)
>>>>>> v_plane!0 = "lat"
>>>>>> v_plane!1 = "lon"
>>>>>> v_plane&lat = lat
>>>>>> v_plane&lon = lon
>>>>>> V = v_plane({5:15},{-30:10})
>>>>>> printVarSummary(V)
>>>>>>
>>>>>>
>>>>>> I am now getting a different error:
>>>>>>
>>>>>> Variable: v_plane
>>>>>> Type: float
>>>>>> Total Size: 60604 bytes
>>>>>> 15151 values
>>>>>> Number of Dimensions: 2
>>>>>> Dimensions and sizes: [109] x [139]
>>>>>> Coordinates:
>>>>>> Number Of Attributes: 4
>>>>>> description : v Velocity
>>>>>> units : m/s
>>>>>> _FillValue : -999999
>>>>>> PlotLevelID : 850 hPa
>>>>>> fatal:Variable (lat) is undefined
>>>>>> fatal:Execute: Error occurred at or near line 39 in file NCL_ascii_V700.ncl
>>>>>>
>>>>>> On Dec 11, 2007 1:13 PM, Dennis Shea <shea_at_ucar.edu> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> [1] To use "coordinate subscripting" two conditions must be present:
>>>>>>> [a] the dimensions must be named. The arrays below do not have
>>>>>>> named dimensions.
>>>>>>> [b] The named dimensions must have 1D [not 2D] monotonically
>>>>>>> {in/de}creasing coordinates associated with each named
>>>>>>> dimension.
>>>>>>>
>>>>>>> Note: These are netCDF rules and NCL adheres to the netCDF
>>>>>>> variable model.
>>>>>>> [2] If you have variables that have 2d variable arrays that contain
>>>>>>> coordinates (like WRF XLAT and XLONG variables] you
>>>>>>> can not use coordinate subscripting [See 1b above ]
>>>>>>>
>>>>>>> [3] Pls read
>>>>>>> http://www.ncl.ucar.edu/Document/Language/cv.shtml
>>>>>>> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml
>>>>>>>
>>>>>>> Erik Noble wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi.
>>>>>>>> I added a printVarSummary(v_plane) to the code to see the error more clearly.
>>>>>>>> The error still remains (below).
>>>>>>>>
>>>>>>>> any suggestions?
>>>>>>>> -erik
>>>>>>>>
>>>>>>>>
>>>>>>>> Variable: v_plane
>>>>>>>> Type: float
>>>>>>>> Total Size: 60604 bytes
>>>>>>>> 15151 values
>>>>>>>> Number of Dimensions: 2
>>>>>>>> Dimensions and sizes: [109] x [139]
>>>>>>>> Coordinates:
>>>>>>>> Number Of Attributes: 4
>>>>>>>> description : v Velocity
>>>>>>>> units : m/s
>>>>>>>> _FillValue : -999999
>>>>>>>> PlotLevelID : 850 hPa
>>>>>>>> fatal:Dimension (1) of (v_plane) is not named and therefore doesn't
>>>>>>>> have an associated coordinate variable
>>>>>>>> fatal:Execute: Error occurred at or near line 37 in file NCL_ascii_V700.ncl
>>>>>>>>
>>>>>>>>
>>>>>>>> On Dec 11, 2007 12:31 PM, Erik Noble <enoble_at_giss.nasa.gov> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Dear NCL,
>>>>>>>>> I am trying to use coordinate subscripting to pull data from an array:
>>>>>>>>> V = v_plane({5:15},{-30:10})
>>>>>>>>> I am getting the error below.
>>>>>>>>> My code is attached.
>>>>>>>>> My I have some help?
>>>>>>>>> Thank you for your help.
>>>>>>>>> -Erik
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Erik_at_noble:/Volumes/Data_and_Models/ncl_scripts:ncl NCL_ascii_V700.ncl
>>>>>>>>> Copyright (C) 1995-2007 - All Rights Reserved
>>>>>>>>> University Corporation for Atmospheric Research
>>>>>>>>> NCAR Command Language Version 5.0.0
>>>>>>>>> The use of this software is governed by a License Agreement.
>>>>>>>>> See http://www.ncl.ucar.edu/ for more details.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Variable: times
>>>>>>>>> Type: string
>>>>>>>>> Total Size: 1948 bytes
>>>>>>>>> 487 values
>>>>>>>>> Number of Dimensions: 1
>>>>>>>>> Dimensions and sizes: [487]
>>>>>>>>> Coordinates:
>>>>>>>>> Number Of Attributes: 2
>>>>>>>>> description : times in file
>>>>>>>>> _FillValue : missing
>>>>>>>>>
>>>>>>>>> Variable: v
>>>>>>>>> Type: float
>>>>>>>>> Total Size: 1636308 bytes
>>>>>>>>> 409077 values
>>>>>>>>> Number of Dimensions: 3
>>>>>>>>> Dimensions and sizes: [27] x [109] x [139]
>>>>>>>>> Coordinates:
>>>>>>>>> Number Of Attributes: 2
>>>>>>>>> description : v Velocity
>>>>>>>>> units : m/s
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Variable: u
>>>>>>>>> Type: float
>>>>>>>>> Total Size: 1636308 bytes
>>>>>>>>> 409077 values
>>>>>>>>> Number of Dimensions: 3
>>>>>>>>> Dimensions and sizes: [27] x [109] x [139]
>>>>>>>>> Coordinates:
>>>>>>>>> Number Of Attributes: 2
>>>>>>>>> description : u Velocity
>>>>>>>>> units : m/s
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Variable: u
>>>>>>>>> Type: float
>>>>>>>>> Total Size: 1636308 bytes
>>>>>>>>> 409077 values
>>>>>>>>> Number of Dimensions: 3
>>>>>>>>> Dimensions and sizes: [27] x [109] x [139]
>>>>>>>>> Coordinates:
>>>>>>>>> Number Of Attributes: 2
>>>>>>>>> description : u Velocity
>>>>>>>>> units : m/s
>>>>>>>>> fatal:Dimension (1) of (v_plane) is not named and therefore doesn't have an
>>>>>>>>> associated coordinate variable
>>>>>>>>> fatal:Execute: Error occurred at or near line 37 in file NCL_ascii_V700.ncl
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Erik_at_noble:/Volumes/Data_and_Models/ncl_scripts:
>>>>>>>>>
>>>>>>>>>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 12 2007 - 09:27:10 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 12 2007 - 16:19:09 MST