<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<br class=""><div dir="ltr" class=""><div class="">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in file reaadworkcsv.ncl</div></div><div class=""><br class=""></div><div class="">This usually means you’re trying to set say 15 values to an array that previously only held 10. </div><div class="">NCL is not flexible with array sizes once they are defined. </div><div class="">At the bottom of loops either delete() or use the := notation to redefine where needed. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Check what ever is happening on line 51. Should the return value always be the same length (through each loop) or do you expect them to vary?</div><div class="">You can redefine the return variable each time easily by using := instead of = </div><div class="">I think the first edit would be</div><div class="">seldata1 := str_match_ic_regex(seldata, strkey)</div><div class=""><br class=""></div><div class="">The print(dimsizes()) suggests you expect the size to vary. You’ll likely need to do the same thing on the lines that also use seldata1 later in the script. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 4 Nov 2015, at 13:56, Adv <<a href="mailto:advita6@gmail.com" class="">advita6@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi,<br class=""><br class=""></div><div class="">Thanks for your reply. Sorry for the misrepresentation. <br class=""></div><div class="">I printed below the error output. <br class=""></div><div class="">While the loop starting for the second time I get this error. I am sure that the representation to calculate average of all the jan months are right.<br class=""><br class=""></div><div class="">I tried to create two domensional array which is commented in the code to write output. But that is not a problem. <br class=""></div><div class="">why particularly error in this specific line for the second time loop is what i don't understand. There is no dimension error for the first time. But for the second one. <br class=""><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;color:rgb(34,34,34);font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/0B5aDji6ggKPARHlEUW9Ta0tMZG8/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px 0;border:none" class=""><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" class=""> <span dir="ltr" style="color:rgb(17,85,204);text-decoration:none;vertical-align:bottom" class="">minnesota50.csv</span></a><img src="x-msg://ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; display: none;" class=""></div><br class=""><br class=""><br class=""></div><div class="">Thank you, <br class=""></div><div class=""><br class="">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<br class="">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in file reaadworkcsv.ncl<br class=""><br class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 4, 2015 at 12:30 PM, Alan Brammer <span dir="ltr" class=""><<a href="mailto:abrammer@albany.edu" target="_blank" class="">abrammer@albany.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Had this folder open so I’ll give you a quick reply.<br class="">
<br class="">
There’s a lot of code here and no explanation of why you need help?<br class="">
Although it sometimes resembles it I believe this list isn’t really intended as a place to just quickly outsource your scripting desires.<br class="">
<br class="">
What have you tried?<br class="">
What specific issue did you run into?<br class="">
How is anyone on here supposed to know your data layout?<br class="">
Have you looked at the numerous climatology examples and previous ncl-talk questions?<br class="">
Where did the answers to the above questions fall short and thus what specifically is the problem?<br class="">
<br class="">
Good luck. As always direct replies to the list. Hopefully a more specific question lends it self to a more specific answer.<br class="">
<br class="">
<br class="">
Alan.<br class="">
<div class=""><div class="h5"><br class="">
<br class="">
> On 4 Nov 2015, at 13:23, Adv <<a href="mailto:advita6@gmail.com" class="">advita6@gmail.com</a>> wrote:<br class="">
><br class="">
> Hi NCL user,<br class="">
><br class="">
> I would like to write final average corresponding to each station, monthly average of 42 years to a two dimensionl array.<br class="">
> Could someone help me to accomplish this?<br class="">
><br class="">
> Thank you,<br class="">
> Adv<br class="">
><br class="">
> begin<br class="">
> ; diri = "./"<br class="">
> fkey = "minnesota"<br class="">
> strs=asciiread("minnesota50.csv" , -1, "string")<br class="">
> n1=(/"197301","197401","197501","197601","197701","197801" \<br class="">
> ,"197901","198001","198101","198201","198301","198401" \<br class="">
> ,"198501","198601","198701","198801","198901","199001" \<br class="">
> ,"199101","199201","199301","199401","199501","199601" \<br class="">
> ,"199701","199801","199901","200001","200101","200201","200301" \<br class="">
> ,"200401","200501","200601","200701","200801","200901" \<br class="">
> ,"201001","201101","201201","201301","201401"/)<br class="">
> print(n1)<br class="">
> ns1 = dimsizes(n1)<br class="">
> print(ns1)<br class="">
> do j =0, dimsizes(n1)-1<br class="">
><br class="">
> ; yyyymm = 197301<br class="">
> yyyymm = n1(j)<br class="">
> fldstr = "PRCP" ; case sensitive<br class="">
> con = 1.00<br class="">
> print(yyyymm)<br class="">
> ;return<br class="">
> ;***********************************************<br class="">
> ; match all data lines with specified YYYYYY<br class="">
> ;***********************************************<br class="">
><br class="">
> ; seldata = str_match_ic_regex(strs, tostring(yyyymm)) ; 6.3.0<br class="">
> seldata = str_match_ic_regex(strs, tostring(yyyymm)) ; 6.3.0<br class="">
> ; print(seldata)<br class="">
> print("=====")<br class="">
> n=(/"THIEF","PARK"/)<br class="">
> print(n)<br class="">
> ns = dimsizes(n)<br class="">
> print(ns)<br class="">
> tim = new((/ns1,ns/),"float")<br class="">
> printVarSummary(tim)<br class="">
> ;tavg = new((/ns1,ns/),"float")<br class="">
> tavg = new(ns,float)<br class="">
> print(tavg)<br class="">
> do i =0, dimsizes(n)-1<br class="">
> strkey = n(i)<br class="">
> print(strkey)<br class="">
> ;strkey= "THIEF"<br class="">
> ;print(strkey)<br class="">
> ;return<br class="">
> ; find all lines (rows) which contain the key string<br class="">
><br class="">
> seldata1 = str_match_ic_regex(seldata, strkey) ; 6.3.0 onward<br class="">
> print(seldata1)<br class="">
> print(dimsizes(seldata1))<br class="">
> ;***********************************************<br class="">
> ; write selected data to ascii file<br class="">
> ;***********************************************<br class="">
> seldir = "./"<br class="">
> selfil = fkey+"."+yyyymm+".csv"<br class="">
> system("/bin/rm -f "+seldir+selfil)<br class="">
> asciiwrite(seldir+selfil, seldata1) ; all data for selected yyyymm<br class="">
> ;***********************************************<br class="">
> ; Which field matches<br class="">
> ;***********************************************<br class="">
> FIELDS = (/"STATION","STATION_NAME","ELEVATION","LATITUDE","LONGITUDE" \<br class="">
> ,"DATE","MDPR","MDSF","DAPR","DASF","PRCP","SNWD","SNOW" \<br class="">
> ,"TMAX","TMIN","TOBS" /)<br class="">
><br class="">
><br class="">
> nfield = ind(FIELDS.eq.fldstr) + 1 ; field to be extracted<br class="">
> print("fldstr="+fldstr+" corresponds to field number "+nfield)<br class="">
> print("=====")<br class="">
> ;***********************************************<br class="">
> ; extract the values<br class="">
> ;***********************************************<br class="">
><br class="">
> sdat = str_get_field(seldata1 , 2, ",")<br class="">
> ;*********Monthly average********************************<br class="">
> data = tofloat( str_get_field(seldata1 , nfield, ",") )*con<br class="">
> data@_FillValue = -9999*con<br class="">
> print(sdat+" : "+data)<br class="">
> print("=====")<br class="">
> ;print(data)<br class="">
> ;return<br class="">
> tavg(i)=avg(data)<br class="">
> end do<br class="">
> print(tavg)<br class="">
> ;tim(j,i)=tavg<br class="">
> end do<br class="">
><br class="">
><br class="">
><br class="">
</div></div>> _______________________________________________<br class="">
> ncl-talk mailing list<br class="">
> <a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
> List instructions, subscriber options, unsubscribe:<br class="">
> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>