create longitude and latitude in netcdf

From: Jiaxin Zhang <jiaxinzhang3_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 26 2013 - 17:12:26 MDT

Thank you so much, Dennis!

I have modified the ncl code (deleting .0 gives integer values in the y
calculation) and now the lon computation is correct (attached file).

But I still have one issue. I need to add lat and lon as coordinate
variables for air temperature. According to the second condition that you
mentioned, lat and lon should be not only variables but also dimensions,
right? The new netcdf has only 1 dimension (land), and I guess it would be
necessary to add lat and lon as dimensions. Then, probably all 3
requirements would be satisfied for both lat and lon, and it would be
possible to add them as coordinate variables for air temperature.

I was trying to add lat and lon as dimensions in the last part of the first
code version that I sent (the strange part of the code that you mentioned),
but it did not work (problems with dimensions). I guess there is a way to
do it, but I did not find it in the NCL documents that I checked. How is it
possible to add lat and lon as dimensions in the file? How is it possible
to add lat and lon as coordinate variables for air temperature? What has to
be modified in the attached ncl code to do this part successfully?

Thank you!

Jiaxin Zhang

2013/6/26 Dennis Shea <shea@ucar.edu>

> The script you attached is rather confusing.
> Basically, the file contains land only grid pts
> in a one dimensional array. The lat and lon values
> can only be reconstructed for the land points.
>
> The file has a varaible
> land(land)
>
> This is known as a 'coordinate variable' (CV) in netCDF-speak
>
> http://www.unidata.ucar.edu/**software/netcdf/docs/**
> coordinate_variables.html<http://www.unidata.ucar.edu/software/netcdf/docs/coordinate_variables.html>
>
> Requirements for a CV
> (1) one dimensional
> (2) dimension name ('land') is the same as the variable name
> [land(land)]
> (3) numeric, monotonically increasing or decreasing values
>
> The land(land) satisfies the first two conditions but fails [3].
>
> CVs have a special status in NCL. Since this is not a CV the
> attached script addresses the issue.
>
> ==
> No idea why you did
>
> temp!0 = "newland"
> temp!1 = "newlat"
> temp!2 = "newlon"
>
> temp&newland = land
> temp&newlat = lat
> temp&newlon = lon
> ===
>
> NOTE: the lat computation looks good. The lon computation is
> not correct. It is your responsibility to fix that.
> Always examine the output from printVarSummary(...)
>
>
>
>
> On 6/25/13 5:26 PM, Jiaxin Zhang wrote:
>
>> Hi,
>>
>>
>>
>> I am a new NCL user. After having a look at the NCL Mini-Language Manual
>> and other resources in the NCL website I still could not find a solution
>> for this problem.
>>
>>
>>
>> I have a netcdf file (attached file "tair_2010_model_1time.nc") with air
>> temperature values and the only coordinates in the file are land numbers
>> (calculated from longitude and latitude values). However, I need to add
>> the
>> traditional coordinates with longitude and latitude associated with air
>> temperature values in the netcdf file.
>>
>>
>>
>> To calculate back longitude and latitude values from land values, there
>> are
>> the following equations:
>>
>>
>>
>> y = INT( (land 1) / 360) ! lat index from 0 to 179
>>
>> x = land 360 * y ! lon index from 1 to 360
>>
>> lat = 89.5 y
>>
>> lon = -179.5 + x 1
>>
>>
>>
>> I tried to do these calculations and create the variables y, x, lat and
>> lon
>> in a new netcdf file and apparently this part works (can anyone please let
>> me know if this part is correct in the attached ncl code "newlonlat.ncl"?
>> It is the first time I am creating new variables in a netcdf file and I am
>> not completely sure that this is the best way to do it. I have used the
>> function "toint" to convert y to integer values). But one of the main
>> problems seems to be related with the number of dimensions. The original
>> netcdf has only 1 dimension (land), whereas in the new netcdf, I would
>> need
>> to have more dimensions (at least longitude and latitude), and it seems
>> that this gives an error message. Also, longitude and latitude should be
>> coordinate variables for air temperature in the new netcdf file.
>>
>>
>>
>> Could anyne please help me to find where the error lies and modify the
>> attached script to create the correct netcdf file, including new values
>> for
>> longitude and latitude as coordinate variables for air temperature?
>>
>>
>>
>> Any help will be very appreciated!
>>
>>
>>
>> Thank you!
>>
>>
>>
>> Jiaxin Zhang
>>
>>
>>
>> ______________________________**_________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>
>>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Wed Jun 26 17:12:35 2013

This archive was generated by hypermail 2.1.8 : Mon Jul 01 2013 - 12:35:42 MDT