<div dir="ltr">Hi:<div><br></div><div>Please also respond to the list. Someone on the list might be able to help you faster than I can. Also, members of the list can learn useful information from this exchange.</div><div><br></div><div>It would be helpful if you would verify where the script fails, whether it is the one you are using or a called routine.</div><div><br></div><div>Lastly, the script is telling you that your variable is missing information about what it is. You need to name it, as shown in the NCL help pages.</div><div><br></div><div>But, before you do that, try reading your 4d array into a 2d array and see if you get the same error using the 2d array.</div><div><br></div><div> Barry</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 31, 2019 at 8:59 AM ANDIKA FAUZIAH HAPSARI, A.P <<a href="mailto:andika.hapsari@bmkg.go.id">andika.hapsari@bmkg.go.id</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div style="font-size:13.3333px;font-family:tahoma;color:rgb(0,0,0);font-weight:400;font-style:normal"> </div>
<div style="font-size:13.3333px;font-family:tahoma;color:rgb(0,0,0);font-weight:400;font-style:normal">Thanks for your answer. But I'm not sure if I can pass the 4D variable directly. Because when I used this script below, I got this error message :</div>
<div style="font-size:13.3333px;font-family:tahoma;color:rgb(0,0,0);font-weight:400;font-style:normal">
<div>warning:Argument 0 of the current function or procedure was coerced to the appropriate type and thus will not change if the function or procedure modifies its value<br>
fatal:["NclAtt.c":262]:Attribute assignment type mismatch.</div>
<div>fatal:(lon) is not a named dimension in variable (inData).<br>
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 36 in file $NCARG_ROOT/lib/ncarg/nclscripts/contrib/kf_filter.ncl</div>
<div>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 234 in file filter_vertical_waves_wrf.ncl</div>
<div> </div>
<div> </div>
</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">Or maybe, is there something wrong with my script?</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">Thanks in advance</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
<div> </div>
<div>
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
; filter_waves.ncl<br>
; Carl Schreck (<a href="mailto:carl@cicsnc.org" target="_blank">carl@cicsnc.org</a>)<br>
; February 2011<br>
; Updated for style October 2011<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
; Description: Filter data for each equatorial wave type<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/kf_filter.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/print_clock.ncl"<br>
;load "~/lib/print_clock.ncl"</div>
<div><br>
begin<br>
<br>
print_clock( "Here we go! " )</div>
<div>; These are some parameters that could be useful to have up top<br>
mis = -999<br>
mis@_FillValue = -999</div>
<div> obsPerDay = 4<br>
if( .not.isvar("varIn") ) then<br>
varIn = "u"<br>
end if<br>
if( .not.isvar("latitudeBand") ) then<br>
latitudeBand = "15N-15N"<br>
end if<br>
print( varIn + "." + latitudeBand )<br>
basePath = "/home/sarihmmm/datareanly/reanalysis/"<br>
pathIn = basePath + "anginU.nc"<br>
pathOut = basePath + "anginU" + varIn + "." + latitudeBand + ".<a href="http://vertkelvin.nc" target="_blank">vertkelvin.nc</a>"</div>
<div> wk99 = False ; True uses the original Wheeler-Kiladis filters,<br>
; False uses slight modifications from recent papers<br>
calcHigh = False<br>
calcLow = False<br>
calcMrg = False<br>
calcMjo = False<br>
calcKelvin = True<br>
calcEr = False<br>
calcMtd = False<br>
calcTd = False<br>
makeNewFile = True</div>
<div>; Open the input files<br>
fin = addfile( pathIn, "r" )<br>
time = fin->time<br>
level = fin->level<br>
longitude = fin->longitude<br>
latitude = fin->latitude</div>
<div>; Open the output files<br>
setfileoption( "nc", "Format", "LargeFile" )<br>
if( makeNewFile ) then<br>
system( "rm " + pathOut )<br>
fout = addfile( pathOut, "c" )<br>
fout->time = time<br>
fout->level = level<br>
fout->longitude = longitude<br>
fout->latitude = latitude<br>
else<br>
fout = addfile( pathOut, "w" )<br>
end if</div>
<div> print_clock( "Reading the input data... " )</div>
<div> data = fin->$varIn$<br>
data&time@beginning_date = cd_string( data&time(0), "" )<br>
data&time@ending_date = cd_string( data&time(dimsizes(data&time)-1), "" )</div>
<div> if( any( ismissing(data) ) ) then<br>
print_clock( "WARNING: Setting missing data to zero" )<br>
data = where( ismissing(data), 0, data )<br>
end if</div>
<div> printVarSummary(data)</div>
<div> if( calcHigh ) then<br>
print_clock( "Filtering High..." )</div>
<div> high = data<br>
high@longitudeg_name = "High frequency"<br>
high@filter = "Highpass time filter"<br>
high@wavenumber = (/ -9999, 9999 /)<br>
high@period = (/ 0.01, 120 /)<br>
high@depth = (/ mis, mis /)</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> high(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
high@period(0), high@period(1), \\<br>
high@wavenumber(0), high@wavenumber(1), \\<br>
high@depth(0), high@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing high... " )<br>
fout->high = high<br>
delete(high)<br>
end if</div>
<div><br>
if( calcLow ) then<br>
print_clock( "Filtering Low..." )</div>
<div> low = data<br>
low@longitudeg_name = "Low frequency"<br>
low@filter = "Lowpass time filter"<br>
low@wavenumber = (/ -9999, 9999 /)<br>
low@period = (/ 120, 9999 /)<br>
low@depth = (/ mis, mis /)</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> low(time|:,{level|level(z)},longitude|:,latitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:,latitude|:), obsPerDay, \\<br>
low@period(0), low@period(1), \\<br>
low@wavenumber(0), low@wavenumber(1), \\<br>
low@depth(0), low@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing Low... " )<br>
fout->low = low<br>
delete(low)<br>
end if</div>
<div><br>
if( calcMrg ) then<br>
print_clock( "Filtering MRG..." )</div>
<div> mrg = data<br>
mrg@longitudeg_name = "Mixed Rossby-Gravity Waves in " + str_upper(varIn)<br>
mrg@filter = "Wheeler & Kiladis (1999)"<br>
mrg@wavenumber = (/ -10, -1 /)<br>
mrg@period = (/ 3, 96 /)<br>
mrg@depth = (/ 8, 90 /)</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> mrg(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
mrg@period(0), mrg@period(1), \\<br>
mrg@wavenumber(0), mrg@wavenumber(1), \\<br>
mrg@depth(0), mrg@depth(1), \\<br>
"mrg" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing MRG... " )<br>
fout->mrg = mrg<br>
delete(mrg)<br>
end if</div>
<div><br>
if( calcMjo ) then<br>
print_clock( "Filtering MJO..." )</div>
<div> mjo = data<br>
mjo@longitudeg_name = "Madden-Julian Oscillatitudeion in " + str_upper(varIn)<br>
if( wk99 ) then<br>
mjo@filter = "Wheeler & Kiladis (1999)"<br>
mjo@wavenumber = (/ 1, 5 /)<br>
; mjo@wavenumber = (/ 0, 9 /)<br>
mjo@period = (/ 30, 96 /)<br>
mjo@depth = (/ mis, mis /)<br>
else<br>
mjo@filter = "Kiladis et al. (2005 JAS)"<br>
mjo@wavenumber = (/ 0, 9 /)<br>
mjo@period = (/ 20, 100 /)<br>
mjo@depth = (/ mis, mis /)<br>
end if</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> mjo(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
mjo@period(0), mjo@period(1), \\<br>
mjo@wavenumber(0), mjo@wavenumber(1), \\<br>
mjo@depth(0), mjo@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing MJO... " )<br>
fout->mjo = mjo<br>
delete(mjo)<br>
end if</div>
<div><br>
if( calcKelvin ) then<br>
print_clock( "Filtering KELVIN..." )</div>
<div> kelvin = data<br>
kelvin@longitudeg_name = "Kelvin Waves in " + str_upper(varIn)<br>
if( wk99 ) then<br>
kelvin@filter = "Wheeler & Kiladis (1999)"<br>
kelvin@wavenumber = (/ 1, 14 /)<br>
kelvin@period = (/ 2.5, 30 /)<br>
kelvin@depth = (/ 8, 90 /)<br>
else<br>
kelvin@filter = "Straub & Kiladis (2002)"<br>
kelvin@wavenumber = (/ 1, 14 /)<br>
kelvin@period = (/ 2.5, 17 /)<br>
kelvin@depth = (/ 5, 90 /)<br>
end if</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
do y = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> kelvin(time|:,{level|level(z)},{latitude|latitude(y)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},{latitude|latitude(y)},longitude|:), obsPerDay, \\<br>
kelvin@period(0), kelvin@period(1), \\<br>
kelvin@wavenumber(0), kelvin@wavenumber(1), \\<br>
kelvin@depth(0), kelvin@depth(1), \\<br>
"kelvin" ) /)</div>
<div> end do<br>
end do</div>
<div> print_clock( "Writing KELVIN... " )<br>
fout->kelvin = kelvin<br>
delete(kelvin)<br>
end if</div>
<div><br>
if( calcEr ) then<br>
print_clock( "Filtering ER..." )</div>
<div> er = data<br>
er@longitudeg_name = "Equatorial Rossby Waves in " + str_upper(varIn)<br>
if( wk99 ) then<br>
er@filter = "Wheeler & Kiladis (1999)"<br>
er@wavenumber = (/ -10, -1 /)<br>
er@period = (/ 9.7, 48 /)<br>
er@depth = (/ 8, 90 /)<br>
else<br>
er@filter = "Kiladis et al. (2009 Rev. Geophys.)"<br>
er@wavenumber = (/ -10, -1 /)<br>
er@period = (/ 9.7, 48 /)<br>
er@depth = (/ 5, 90 /)<br>
end if</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> er(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
er@period(0), er@period(1), \\<br>
er@wavenumber(0), er@wavenumber(1), \\<br>
er@depth(0), er@depth(1), \\<br>
"er" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing ER... " )<br>
fout->er = er<br>
delete(er)<br>
end if</div>
<div> if( calcMtd ) then<br>
print_clock( "Filtering MRG/TD..." )</div>
<div> td = data<br>
td@longitudeg_name = "MRG/TD in " + str_upper(varIn)<br>
td@filter = "Frank and Roundy (2006), extended to wavenumber -20"<br>
td@wavenumber = (/ -20, -0 /)<br>
td@period = (/ 2.5, 10 /)<br>
td@depth = (/ mis, mis /)</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> td(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
td@period(0), td@period(1), \\<br>
td@wavenumber(0), td@wavenumber(1), \\<br>
td@depth(0), td@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing TD... " )<br>
fout->td = td<br>
delete(td)<br>
end if</div>
<div><br>
if( calcTd ) then<br>
print_clock( "Filtering TD..." )</div>
<div> td = data<br>
td@longitudeg_name = "TD-type Disturbances in " + str_upper(varIn)<br>
td@filter = "Roundy and Frank (2004), extended to wavenumber -20"<br>
td@wavenumber = (/ -20, -6 /)<br>
td@period = (/ 2.5, 5 /)<br>
td@depth = (/ 90, mis /)</div>
<div> do z = 0, ( dimsizes(level) - 1 )<br>
; print_clock( z + " " + ( dimsizes(level) - 1 ) + " " )</div>
<div> td(time|:,{level|level(z)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{level|level(z)},longitude|:), obsPerDay, \\<br>
td@period(0), td@period(1), \\<br>
td@wavenumber(0), td@wavenumber(1), \\<br>
td@depth(0), td@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing TD... " )<br>
fout->td = td<br>
delete(td)<br>
end if</div>
<div><br>
print_clock( "Closing file..." )<br>
delete(fout)</div>
<div> print_clock( "Thank you, come again. " )</div>
<div>end ; filter_waves</div>
<div> </div>
</div>
<blockquote style="padding-right:0px;padding-left:5px;margin-left:5px;border-left:2px solid rgb(0,0,0);margin-right:0px">From: "Barry Lynn (<a href="mailto:barry.h.lynn@gmail.com" target="_blank">barry.h.lynn@gmail.com</a>)" <<a href="mailto:barry.h.lynn@gmail.com" target="_blank">barry.h.lynn@gmail.com</a>><br>
To: "ANDIKA FAUZIAH HAPSARI, A.P" <<a href="mailto:andika.hapsari@bmkg.go.id" target="_blank">andika.hapsari@bmkg.go.id</a>><br>
Cc: "<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
Date: Tue, 31 Dec 2019 07:48:15 +0200<br>
Subject: Re: [ncl-talk] Loop Over Latitude and Level Arrays<br>
<div dir="ltr">Hi:
<div> </div>
<div>When you pass the variable to the kf_filter, you can loop over both over latitude and level, as you pass the 4D variable directly into the routine.</div>
<div> </div>
<div>I am not sure if there is a faster way,</div>
<div> </div>
<div>Barry</div>
</div>
<div class="gmail_quote">
<div class="gmail_attr" dir="ltr">On Mon, Dec 30, 2019 at 8:17 PM ANDIKA FAUZIAH HAPSARI, A.P via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)">Hello..</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)">I have 4 Dimension data (latitude, longitude, level, time) and I want to filter kelvin waves vertically which use kf_filter function that only has time and longitude. And I need to loop over both latitude and level so that the array can pass kf_filter.</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)">Is there any instruction and script to do loop over latitude and level arrays? </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal;background:none 0% 0%/auto repeat scroll padding-box border-box rgba(0,0,0,0)">Thanks in advance.</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
</div>
<div> </div>
--
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">Barry H. Lynn, Ph.D
<div>
<div>Senior Associate Scientist, Lecturer,</div>
<div>
<div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)">
<span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)">
<span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span></div>
<span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)">
<span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div>
</div>
<div> </div>
<div>C.E.O, Weather It Is, LTD<br>
Weather and Climate Focus<br>
<a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>
Jerusalem, Israel<br>
Local: 02 930 9525<br>
Cell: 054 7 231 170<br>
Int-IS: x972 2 930 9525<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br><br></div></div></div></div></div>