Re: Having problem with tangent calculation

From: Hobbs, Will R (3244-Affiliate) <William.R.Hobbs_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 05 2012 - 13:18:07 MDT

Soumik

One can convert degrees to radians in NCL in exactly the same way as you
would on a piece of paper; by multiplying by (2pi/360). Like this:

> pi = 3.14159
> latrad = (pi/180.) * lat ;where 'lat' is in an angle in degrees.

Will

 

**********************************************************
Will Hobbs, Ph.D. William.R.Hobbs@jpl.nasa.gov
Jet Propulsion Laboratory
4800 Oak Grove Dr. office: 300-324a
M/S 300-323 phone: (818) 354-0466
Pasadena, CA 91109 fax: (818) 354-0966
**********************************************************
 

On 9/5/12 12:09 PM, "Soumik Basu" <sbasu@iarc.uaf.edu> wrote:

>
>Thank you so much for the reply. I used "doubletofloat" and it fixed
>the problem but units are in "degrees_north".
>So is it possible to convert the degrees_north to radians using any
>function in NCL?
>
>Thanks,
>Soumik
>
>
>On 2012-09-05 09:56, shea@ucar.edu wrote:
>> This is a common issue that has been mentioned numerous times on
>> ncl-talk.
>>
>> Speculation: variable is type double.
>> lat = in->lat
>> printVarSummary(lat)
>>
>> Speculation: variable 'tans' is type float.
>> printVarSummary(tans)
>>
>> NCL does not allow a double to be placed into a variable of float.
>> That is exactly what the error message is telling you.
>>
>> The right hand side is double, the left hand side is float.
>> If it was reversed, NCL would not complain
>>
>> Perhaps above, you have defined
>>
>> tans = new ( nlat, "float") change that to "double"
>>
>> ---
>>
>>
>> Actually, you need not decalre a 'new' variable
>>
>> lat = in->lat
>> tans = tan(lat) ; automatically create an array named tans
>>
>> Also, please look at the units of 'lat'.
>> If they are (say) 'degrees_north' then the above
>> will not give the correct answer!!! *All* the trigonometric
>> functions require *radians* as noted in the documentation.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Hi,
>>>
>>> I am trying to calculate term like tan(phi) where phi is the
>>> latitude.
>>> But when I am using the function "tan" it is giving me this error
>>> message.
>>>
>>> fatal:Assignment type mismatch, right hand side can't be coerced to
>>> type of left hand side
>>>
>>> I tried reading the lat from the model file and pass it to the
>>> function
>>> as an array.
>>>
>>> lat = in->lat
>>>
>>> do k = 0,nlat-1
>>>
>>> tans(k) = tan (lat(k))
>>>
>>> end do
>>>
>>> Can anybody please suggest what did I need to do make it work.
>>>
>>> Thanks,
>>> Soumik
>>>
>>> --
>>> "Numbing the pain for a while will make it worse when you finally
>>> feel
>>> it.
>>> ~J.K. Rowling"
>>> *****************************************
>>> Soumik Basu
>>> Graduate Student, Research Assistant
>>> International Arctic Research Center
>>> University of Alaska Fairbanks
>>> Fairbanks,Alaska,USA
>>> *****************************************
>>> _______________________________________________
>>> 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
>
>--
>"Numbing the pain for a while will make it worse when you finally feel
>it.
> ~J.K. Rowling"
>*****************************************
>Soumik Basu
>Graduate Student, Research Assistant
>International Arctic Research Center
>University of Alaska Fairbanks
>Fairbanks,Alaska,USA
>*****************************************
>_______________________________________________
>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 Sep 5 13:18:22 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT