Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Latitudes and longitudes from convert_mpas

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

kgurer777

New member
Hello,

I am trying to fully understand how "convert_mpas" routine works and how I should interpret its results. I have been examining the code for this purpose, but I need further interpretation please. The routine is fast and extracted values of 3D variables agree well with the global domain values.

When I convert "latCell" and "lonCell" variables of MPAS output into lat/lon grid using "convert_mpas" routine, the values of the variables are created for the 2D lat/lon coordinates of the target domain that I want to get the data in. While the coordinates are in degrees, the data comes in radian:

--------------------------------------------------------------------
(0) reading -- lat --

Variable: lat2d
Type: float
Total Size: 42336 bytes
10584 values
Number of Dimensions: 2
Dimensions and sizes: [latitude | 98] x [longitude | 108]
Coordinates:
latitude: [31.6178..42.50189]
longitude: [-129.0292..-113.0208]
Number Of Attributes: 2
units : rad
long_name : Latitude of cells
(0) Latitude of cells (rad) : min=0.551835 max=0.741798
(0) ---------------
(0) reading -- lon --

Variable: lon2d
Type: float
Total Size: 42336 bytes
10584 values
Number of Dimensions: 2
Dimensions and sizes: [latitude | 98] x [longitude | 108]
Coordinates:
latitude: [31.6178..42.50189]
longitude: [-129.0292..-113.0208]
Number Of Attributes: 2
units : rad
long_name : Longitude of cells
(0) Longitude of cells (rad) : min=4.0312 max=4.3106
(0) min=0.0854768 max=17.7317
-----------------------------------------------------------------------------------

When I try to convert the data points from radian to degrees by multiplying the data via clipped ncl script below:

------------------------------------------------------------------------------------
r2d = 180.0/(atan(1)*4.0)

lat2d = a->latCell * r2d
printVarSummary(lat2d)
printMinMax(lat2d,0)

print("---------------")
print("reading -- lon2d --")

lon2d = a->lonCell * r2d
printVarSummary(lon2d)
printMinMax(lon2d,0)

then the output is:
----------------------------------------------------------------------
(0) reading -- lat --

Variable: lat2d
Type: float
Total Size: 42336 bytes
10584 values
Number of Dimensions: 2
Dimensions and sizes: [98] x [108]
Coordinates:
(0) min=31.6178 max=42.5019
(0) ---------------
(0) reading -- lon --

Variable: lon2d
Type: float
Total Size: 42336 bytes
10584 values
Number of Dimensions: 2
Dimensions and sizes: [98] x [108]
Coordinates:
(0) min=230.971 max=246.979
(0) min=0.0854768 max=17.7317
----------------------------------------------------------------------
In this case, "Coordinates" of both latCell and lonCell are lost, lat2d values are in the correct range but lon2d values are now flipped from "-180/180" to "0/360" range. What am I doing wrong here, or, am I interpreting the results incrorrectly? Is multiplying the latCell and lonCell with r2d wrong and why the multiplication eliminates the coordinates?

How can I fix this problem and convert latCell and lonCell into 2d lat/lon grid with correct degree values?

I appreciate your help very much. Thank you.

Kemal.
 
I don't think I'm completely following your workflow, but multiplying the latitudes and longitudes in radians by 180.0/(atan(1.0)*4.0) should be fine.

At what point are the Coordinates added? This isn't something that the convert_mpas program provides. Do you have an NCL script that processes the output of the convert_mpas program?
 
Top