Hi all,
I have a big matrix, which I want to surf plot. However there are actually only values for a non-rectangular shape and i want to blank out those other values (which are -999 by default). [a,b]=find(M==-999); M(a,b) = %nan; surf(M); However this gives me a weird all-black surf plot, with a Z up to -1000 ?? Am I'm missing something? cheers richard -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
%nan are not plotted in Scilab 5.5.2.
Either some data point approaches -1000 or condition M==-999 fails to grab all non-valid entries. -----Original Message----- From: users [mailto:[hidden email]] On Behalf Of Richard llom Sent: Tuesday, November 21, 2017 5:42 PM To: [hidden email] Subject: [Scilab-users] surf and %nan Hi all, I have a big matrix, which I want to surf plot. However there are actually only values for a non-rectangular shape and i want to blank out those other values (which are -999 by default). [a,b]=find(M==-999); M(a,b) = %nan; surf(M); However this gives me a weird all-black surf plot, with a Z up to -1000 ?? Am I'm missing something? cheers richard -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
In reply to this post by Richard llom
Hello Richard,
>----- Mail original ----- >Envoyé: Mardi 21 Novembre 2017 17:41:40 > >Hi all, >I have a big matrix, which I want to surf plot. However there are actually >only values for a non-rectangular shape and i want to blank out those other >values (which are -999 by default). > >[a,b]=find(M==-999); >M(a,b) = %nan; The syntax is: M(M==-999) = %nan; or M(find(M==-999)) = %nan; Then surf(M); should be OK. HTH Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
It is not the most compact form but I think there is no issue with original syntax proposed:
[a,b]=find(M==-999); M(a,b) = %nan; -----Original Message----- From: users [mailto:[hidden email]] On Behalf Of [hidden email] Sent: Tuesday, November 21, 2017 6:50 PM To: Users mailing list for Scilab <[hidden email]> Subject: Re: [Scilab-users] surf and %nan Hello Richard, >----- Mail original ----- >Envoyé: Mardi 21 Novembre 2017 17:41:40 > >Hi all, >I have a big matrix, which I want to surf plot. However there are actually >only values for a non-rectangular shape and i want to blank out those other >values (which are -999 by default). > >[a,b]=find(M==-999); >M(a,b) = %nan; The syntax is: M(M==-999) = %nan; or M(find(M==-999)) = %nan; Then surf(M); should be OK. HTH Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
>It is not the most compact form but I think there is no issue with original syntax proposed:
>[a,b]=find(M==-999); >M(a,b) = %nan; In the M(a,b) syntax, a stands for the indices of selected ROWS, and b for the vector of selected COLUMNS, no matter about the fact that a and b have here the same length and then could be -- erroneously -- considered as respective elementwise indices. This is why linearized indices must be used, as returned by i = find(..). --> m = int8(grand(5,5,"uin",0,9)) m = 2 1 5 0 9 2 9 5 9 9 4 5 0 4 3 5 8 6 7 9 4 3 9 6 6 --> m([2 3 5],[1 2 4]) ans = 2 9 9 4 5 4 4 3 6 --> m([2 3 5]',[1 2 4]') ans = 2 9 9 4 5 4 4 3 6 BR _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
For the task requested the same M results are obtained with either syntax:
x=1:100;
y=1:200;
M=
x.*.y';
M(10,11:99)=-999;
M(13,13)=-999;
M2
=
M;
[a,b]=find(M==-999);
M(a,b)
=
%nan;
M2(M2==-999)=
%nan;
-->max(M2-M) ans =
0.
-->min(M2-M) ans = 0.
-----Original Message----- >It is not the most compact form but I think there is no issue with original syntax proposed: >[a,b]=find(M==-999); >M(a,b) = %nan; In the M(a,b) syntax, a stands for the indices of selected ROWS, and b for the vector of selected COLUMNS,
no matter about the fact that a and b have here the same length and then could be -- erroneously -- considered as respective elementwise indices. This is why linearized indices must be used, as returned by
i = find(..). --> m = int8(grand(5,5,"uin",0,9)) m
= 2
1 5
0 9
2 9
5 9
9
4 5
0 4
3
5 8
6 7
9
4 3
9 6
6 --> m([2 3 5],[1 2 4]) ans
=
2 9
9
4 5
4
4 3
6 --> m([2 3 5]',[1 2 4]') ans
=
2 9
9
4 5
4
4 3
6 BR _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Thanks Samuel for highlighting this non trivial point. I take it back as the better test here below indicates that the two syntaxes are not equivalent:
x=1:100;
y=1:200;
M=
x.*.y';
M(10,11:99)=-999;
M(13,13)=-999;
M2
=
M;
[a,b]=find(M==-999);
M(a,b)
=
%nan;
M2(M2==-999)=
%nan;
M(isnan(M))=%pi;
M2(isnan(M2))=%pi;
-->max(M2-M)
ans
=
1283.8584
-->min(M2-M)
ans
=
0. Regards, Rafael -----Original Message----- >It is not the most compact form but I think there is no issue with original syntax proposed: >[a,b]=find(M==-999); >M(a,b) = %nan; In the M(a,b) syntax, a stands for the indices of selected ROWS, and b for the vector of selected COLUMNS,
no matter about the fact that a and b have here the same length and then could be -- erroneously -- considered as respective elementwise indices. This is why linearized indices must be used, as returned by
i = find(..). --> m = int8(grand(5,5,"uin",0,9)) m
= 2
1 5
0 9
2 9
5 9
9
4 5
0 4
3
5 8
6 7
9
4 3
9 6
6 --> m([2 3 5],[1 2 4]) ans
=
2 9
9
4 5
4
4 3
6 --> m([2 3 5]',[1 2 4]') ans
=
2 9
9
4 5
4
4 3
6 BR _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
The original syntax can be fixed by feeding the
a,b indices found as a 2xN matrix [a;b] into M:
x=1:100;
y=1:200;
M=
x.*.y';
M(10,11:99)=-999;
M(13,13)=-999;
M2
=
M;
[a,b]=find(M==-999);
M([a;b]]) = %nan; // proper away of feeding indices into M
M2(M2==-999)=
%nan;
M(isnan(M))=%pi;
M2(isnan(M2))=%pi;
-->max(M2-M)
ans
=
0.
-->min(M2-M)
ans
=
0. Regards, Rafael -----Original Message----- >It is not the most compact form but I think there is no issue with original syntax proposed: >[a,b]=find(M==-999); >M(a,b) = %nan; In the M(a,b) syntax, a stands for the indices of selected ROWS, and b for the vector of selected COLUMNS,
no matter about the fact that a and b have here the same length and then could be -- erroneously -- considered as respective elementwise indices. This is why linearized indices must be used, as returned by
i = find(..). --> m = int8(grand(5,5,"uin",0,9)) m
= 2
1 5
0 9
2 9
5 9
9
4 5
0 4
3
5 8
6 7
9
4 3
9 6
6 --> m([2 3 5],[1 2 4]) ans
=
2 9
9
4 5
4
4 3
6 --> m([2 3 5]',[1 2 4]') ans
=
2 9
9
4 5
4
4 3
6 BR _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
(now without a typo) The original syntax can be fixed by feeding the
a,b indices found as a 2xN matrix [a;b] into M:
x=1:100;
y=1:200;
M=
x.*.y';
M(10,11:99)=-999;
M(13,13)=-999;
M2
=
M;
[a,b]=find(M==-999);
M([a;b])
=
%nan;
// proper away of feeding indices into M
M2(M2==-999)=
%nan;
M(isnan(M))=%pi;
M2(isnan(M2))=%pi;
-->max(M2-M)
ans
=
0.
-->min(M2-M)
ans
=
0. Regards, Rafael _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
In reply to this post by Rafael Guerra
Hey Rafael & Samuel,
thanks for the replies. However I'm really having a hard time to process this data. This is the raw data in question: ftp://ftp-cdc.dwd.de/pub/CDC/grids_germany/monthly/radiation_diffuse/grids_germany_monthly_radiation_diffuse_201601.zip My minimal script: asc_list = listfiles('*.asc'); asc_idx = 1; asc_file = asc_list(asc_idx); [asc_data, comments] = fscanfMat(asc_file); [a,b] = find(asc_data==-999); asc_data(a,b) = %nan; surf(asc_data); Right now it even fails at processing the -999 to nans... It's like I'm hitting bugs in scilabs? regards richard -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Hi Richard, Scilab 5.5.2: had to use
stacksize('max'), data loaded but surf would not display 866 x 654 matrix Scilab 6: it did not work fine with one of the following syntaxes:
asc_data(asc_data==-999)
=
%nan
surf(asc_data); or with: ix = find(asc_data==-999) asc_data(ix) = %nan surf(asc_data); Note that as shown by Samuel and in the test I produced yesterday, the syntax in your original code produces wrong results: [a,b] = find(asc_data==-999); asc_data(a,b) = %nan; To use the indices
a,b this should be modified as: [a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; However this last syntax seemed to work on yesterday’s test on a much smaller matrix but it is not working on your big one... Not sure
if this is a bug or problem with the syntax, needs further investigation. Regards, Rafael -----Original Message----- Hey Rafael & Samuel, thanks for the replies. However I'm really having a hard time to process this data. This is the raw data in question: My minimal script: asc_list =
listfiles('*.asc'); asc_idx = 1;
asc_file =
asc_list(asc_idx); [asc_data, comments] =
fscanfMat(asc_file); [a,b] = find(asc_data==-999); asc_data(a,b) = %nan; surf(asc_data); Right now it even fails at processing the -999 to nans... It's like I'm hitting bugs in
scilabs? regards richard _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Ok, I corrected the syntax and it works now with regard to the nans:
[a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; The black color btw, seems to be from the edge color, if I do surf(asc_data,'edgecol','white'); it is all white. How can I turn the egdecolor completely off? preferably via suh = get('hdl'); suh.edgecolor = 0; (which doesn't work) regards richard BTW: I'm usinge Win10 and scilab 6 here at work. At home I could test on linux and scilab, however I kind of doubt it is an OS problem. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
In reply to this post by Rafael Guerra
(sorry
for the typo –
corrected below.
Interesting that the last syntax worked for you on your big matrix, it failed for me on Win 7, Scilab 6.0.0) Hi Richard, Scilab 5.5.2: had to use
stacksize('max'), data loaded but surf would not display 866 x 654 matrix Scilab 6:
it did work fine with one of the following syntaxes:
asc_data(asc_data==-999)
=
%nan
surf(asc_data); or with: ix = find(asc_data==-999) asc_data(ix) = %nan surf(asc_data); Note that as shown by Samuel and in the test I produced yesterday, the syntax in your original code produces wrong results: [a,b] = find(asc_data==-999); asc_data(a,b) = %nan; To use the indices
a,b this should be modified as: [a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; However this last syntax seemed to work on yesterday’s test on a much smaller matrix but it is not working on your big one... Not sure
if this is a bug or problem with the syntax, needs further investigation. Regards, Rafael -----Original Message----- Hey Rafael & Samuel, thanks for the replies. However I'm really having a hard time to process this data. This is the raw data in question: My minimal script: asc_list =
listfiles('*.asc'); asc_idx = 1;
asc_file =
asc_list(asc_idx); [asc_data, comments] =
fscanfMat(asc_file); [a,b] = find(asc_data==-999); asc_data(a,b) = %nan; surf(asc_data); Right now it even fails at processing the -999 to nans... It's like I'm hitting bugs in
scilabs? regards richard _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
In reply to this post by Richard llom
Try this:
surf(asc_data);
f=gcf();
f.color_map=hotcolormap(64);
h=get("hdl")
h.color_mode=
-2;
//color according to z
h.color_flag=
2;
//remove the facets boundary Regards, Rafael
Ok, I corrected the syntax and it works now with regard to the nans: [a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; The black color btw, seems to be from the edge color, if I do surf(asc_data,'edgecol','white'); it is all white. How can I turn the
egdecolor completely off? preferably via suh = get('hdl'); suh.edgecolor = 0; (which doesn't work) regards richard BTW: I'm
usinge Win10 and scilab 6 here at work. At home I could test on
linux and scilab, however I kind of doubt it is an OS problem. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Ah, thank you, this looks good!
With my syntax: [a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; I was occasionally still seeing -999 values in the plot (although they weren't in asc_data), I suspect some memory issues maybe... However with asc_data(asc_data==-999) = %nan it is working on every pass. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Not sure if this should be considered a bug in Scilab 6.0 but it looks odd enough.
If you have time, it might be worth reporting it -----Original Message----- From: users [mailto:[hidden email]] On Behalf Of Richard llom Sent: Thursday, November 23, 2017 2:28 PM To: [hidden email] Subject: Re: [Scilab-users] surf and %nan Ah, thank you, this looks good! With my syntax: [a,b] = find(asc_data==-999); asc_data([a;b]) = %nan; I was occasionally still seeing -999 values in the plot (although they weren't in asc_data), I suspect some memory issues maybe... However with asc_data(asc_data==-999) = %nan it is working on every pass. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Actually, I still have a hard time to properly display germany.
a = 1:size(asc_data,1); b = 1:size(asc_data,2); grayplot(a,b,asc_data) neither grayplot(b,a,asc_data') puts it in the right direction...? Reference: https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Deutschland_topo.jpg/800px-Deutschland_topo.jpg Regarding the bug I will do some further investigations first. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
This should fix some of Germany’s problems:
[a,b]
=
size(asc_data);
x
=
1:a;
y
=
1:b;
grayplot(x,y,asc_data)
a=gca();
a.rotation_angles=[0
0];
f=gcf();
f.color_map=hotcolormap(64);
Actually, I still have a hard time to properly display
germany. a = 1:size(asc_data,1); b = 1:size(asc_data,2); grayplot(a,b,asc_data) neither grayplot(b,a,asc_data') puts it in the right direction...? Reference: Regarding the bug I will do some further investigations first. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Thanks Rafael!
Never would have guessed this one (a.rotation_angles=[0 0];)! -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Richard, It is simpler to properly define the x and y axes and to transpose the input data matrix:
[a,b]
=
size(asc_data);
y
=
a:-1:1;
x
=
1:b;
asc_data
=
asc_data';
grayplot(x,y,asc_data)
f=gcf();
f.color_map=hotcolormap(64); Regards, Rafael -----Original Message----- Thanks Rafael! Never would have guessed this one (a.rotation_angles=[0 0];)! _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Free forum by Nabble - Resume Templates | Edit this page |