Re: trouble with calculating the cosine of 2 dimensional latitude

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 17 2012 - 07:58:27 MDT

Alexander,

When you do a calculation like this:

> u = f->U_GRD_GDS5_ISBL_10(i,:,:)/cos(lat)*113000

Any metadata that may have been part of f->U_GRD_GDS54_ISBL_10 will get stripped off (except the _FillValue attribute).

This includes any lat/lon coordinate arrays that may have been attached to your data.

To avoid losing metadata, you can do something like this:

    u = f->U_GRD_GDS5_ISBL_10(i,:,:) ; this retains metadata
    u = u/cos(lat)*113000

--Mary

On Apr 16, 2012, at 11:13 AM, Alexander Semenov wrote:

> Dear NCL-users.
>
> I have a question about calculating the cosine of latitude.
>
> The trouble is that the latitude I'm using is two-dimensional.
>
> float g5_lat_0 ( g5_x_0, g5_y_1 ) - LATITUDE
>
> Do, when I calculate the cosine, the whole domain gets strange. NCL still plots it, but obviously something is going wrong. I attached 2 plots. The parameter I'm trying to calculate should look like the plot "when I don't devide U by cosine". Is there any way to fix that? Thanks
>
> That's the part of my code:
>
> i = 10 ;HEIGHT
> lat = f->g5_lat_0
> printVarSummary(lat)
> lon = f->g5_lon_1
> u = f->U_GRD_GDS5_ISBL_10(i,:,:)/cos(lat)*113000
> v = f->V_GRD_GDS5_ISBL_10(i,:,:)/113000
>
>
>
> --
> regards
>
> *******************************************************
> Alexander Semenov
>
> PhD Student - Research Assistant
> International Arctic Research Center
> Department of atmospheric sciences
> University of Alaska Fairbanks
>
> 930 Koyukuk dr, 408c3
> Fairbanks, AK, USA, 99775
> work phone +19074742672
>
> <when devide U by cosine.png><when I don't devide U by cosine.png>_______________________________________________
> 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 Tue Apr 17 07:58:40 2012

This archive was generated by hypermail 2.1.8 : Fri Apr 20 2012 - 16:21:18 MDT