# Re: create longitude and latitude in netcdf

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 26 2013 - 07:10:00 MDT

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

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

==
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.
>
>
>
> 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
>

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

Received on Wed Jun 26 07:10:13 2013

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