[ncl-talk] Wondering Why I Get This Error
Marston Johnston
shejo284 at gmail.com
Fri Sep 8 02:57:18 MDT 2017
Good that it works. Where statement is a good function to be familiar with.
Is there a similar approach for adding two numbers to the array?
dbz = dbz*0.5 - 0.33
It depends on what you want to do. Are you again thinking element-wise? As it stands above, you are operating on the entire array.
Then the where statement will work:
Dbz = where(condition, dbz*0.5 - 0.33,dbz)
Someone else pointed out that wrap_around is byte. You cannot add a byte and a float, in many low-level languages you have to keep track of such things. Be careful when you coerce a type. Double check that the results is what you want and that there is minimal data loss. Otherwise you will introduce more strange things into your results.
/M
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marston S. Ward, PhD
Department of Earth Sciences
University of Gothenburg, Sweden
Email: marston.johnston at gu.se
SkypeID: marston.johnston
Phone: +46-31-7864901
Only the fruitful thing is true!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Barry Lynn <barry.h.lynn at gmail.com>
Date: Friday, 8 September 2017 at 10:50
To: Marston Johnston <shejo284 at gmail.com>
Cc: ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] Wondering Why I Get This Error
The where statement did the trick for that problem -- thank you.
If you want to check the elements of an array of any dimension and replace that element with a scalar of the same type, then consider the where()
Statement:
Dbz = where(dbz.lt.0.0, dbz+256.0,dbz)
Is there a similar approach for adding two numbers to the array?
dbz = dbz*0.5 - 0.33
Thanks -- this should be the last of my questions abou this.
On Fri, Sep 8, 2017 at 11:46 AM, Marston Johnston <shejo284 at gmail.com> wrote:
Try the where() statement and then printout the meta data on all variables involved in the problem.
/M
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marston S. Ward, PhD
Department of Earth Sciences
University of Gothenburg, Sweden
Email: marston.johnston at gu.se
SkypeID: marston.johnston
Phone: +46-31-7864901
Only the fruitful thing is true!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: Barry Lynn <barry.h.lynn at gmail.com>
Date: Friday, 8 September 2017 at 10:44
To: Marston Johnston <shejo284 at gmail.com>
Cc: ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] Wondering Why I Get This Error
Of course I read the error statement.
I don't understand why I can add dbz (which is a 2 dimensional array) to a scalar value. This is a pretty basic thing to do.
Moreover, when I defined "wrap_around" as dbz, and then set wrap_around to zero, I still can't coerce the variables.
fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 35 in file ./radar_2.ncl
Is the answer to this problem obvious? It seems to me that it should be, which I am (at the moment) frustrated.
wrap_around = dbz
wrap_around = 256.
do j = 0,dims2d(0)-1
do i = 0,dims2d(1)-1
check = ismissing(dbz(j,i))
if (check.eq.False)then
if (dbz(j,i).lt.0)then
dbz(j,i) = dbz(j,i) + wrap_around(j,i)
end if
end if
end do
end do
On Fri, Sep 8, 2017 at 11:37 AM, Marston Johnston <shejo284 at gmail.com> wrote:
Again, read the error statement and try to understand what it is telling you:
atal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 35 in file ./ra
You have a TYPE mismatch between your variables and NCL cannot coerce one to the other. Make sure you are adding the same types of variables…
For example, you cannot do 1 + “help”, that would be a type mismatch!
/M
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marston S. Ward, PhD
Department of Earth Sciences
University of Gothenburg, Sweden
Email: marston.johnston at gu.se
SkypeID: marston.johnston
Phone: +46-31-7864901
Only the fruitful thing is true!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Barry Lynn <barry.h.lynn at gmail.com>
Date: Friday, 8 September 2017 at 10:11
To: ncl-talk <ncl-talk at ucar.edu>
Subject: [ncl-talk] Wondering Why I Get This Error
atal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 35 in file ./ra
--
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581
C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
--
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581
C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170908/e15b35bf/attachment.html>
More information about the ncl-talk
mailing list