Re: [Scilab-users] Filled polygons from polylines

2021-04-14 Thread arctica1963
Many thanks Antoine

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-14 Thread arctica1963
Sorry, I did not make it clear.

Instead of the following which updates the existing graphic to generate the
final plot (y1 to y10);

plot(-[t(n) t], [0 y1])
plot(-[t(n) t], [0 y2])
plot(-[t(n) t], [0 y3])
plot(-[t(n) t], [0 y4])
plot(-[t(n) t], [0 y5])
plot(-[t(n) t], [0 y6])
plot(-[t(n) t], [0 y7])
plot(-[t(n) t], [0 y8])
plot(-[t(n) t], [0 y9])
plot(-[t(n) t], [0 y10])

Can a loop (y) be made to simplify the above for clarity as a single plot
command? Not a big issue but would be good to know.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-14 Thread arctica1963
Truncated plot at t=97

 



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-14 Thread arctica1963
Hi Samuel,

Sorted out the code and it works.Had to manually set the filled areas upper
time limit (t=97) (plot(-[97 t], [0 y1]) ). Set two graphic handles for
upper and lower plot. Just random colours to test!

Is there a way to do a loop over the curves to save multiple plots

Thanks

Lester

 

 

Backstrip_1D_v2filltest.sce
  



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-13 Thread arctica1963
Hi Samuel,

Thanks for the suggestion. I have not managed to get it working with the
existing code as it generates an invalid index error; not sure what is going
on. I tidied up the file for clarity.

Following your example,

plot(x, [0 y3 0]) would be plot(-t, [0 -xu(1,1:n) 0] ) in this code, but
this generates an invalid index. Not sure what is falling over?

I did note that some vertices close to the top border are coincident, which
could cause issues. Will keep working on the problem, but any pointers would
be helpful.

Cheers

Lester

Backstrip_1D_v2.sce
  Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-07 Thread arctica1963
Think I spotted it...

figure(1), clf

f=gcf();
f.figure_size=[1024,800];
f.figure_name = "Subsidence of the Kufrah Basin Well A1-NC198";
f.background=8 // white background


title ('Subsidence of the Kufrah Basin Well A1-NC198') // Figure title

subplot (2,1,1)

a=gca();
a.font_size=3

[f,epoly,ey1,ey2]=BetweenCurves(-t,-xu(2,1:n),-xu(3,1:n),'Handle',f,'axis',a,
'foreground', 12 ) // for each interval

plot (-t,-xu(2,1:n),'b-o',..
  -t,-xu(3,1:n),'b-o',..
  -t,-xu(4,1:n),'b-o',.. etc





--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Filled polygons from polylines

2021-04-07 Thread arctica1963
Hello Antoine,

Your code does seem to work since the x locations are constant for each
curve. However, I cannot see where exactly to apply the code for each layer
within my existing code and how to apply different fill colours.

This works to fill between the 2nd and 3rd polylines (see image):
[epoly,ey1,ey2]=BetweenCurves(-t,-xu(2,1:n),-xu(3,1:n)) // x=time,
y=subsidence

Sure it is something to do with the figure (f) and axes (a) handles.

Could you clarify where things go.

Many thanks

Lester

 



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Filled polygons from polylines

2021-04-07 Thread arctica1963
Hello,

I have script that reads a csv file containing the data and uses that to
calculate subsidence from well information. This all works fine, but it is
not the best way to display the result. Is it possible to take the polyline
output and generate filled polygons (similar to attached image)?

I am not sure how it is possible from the existing code to close the output
result used in the plot function to create a closed polygon. Essentially it
needs extra points otherwise you would just tie the end point and start
point of the polyline.

It would be good to get some other ideas and whether it is actually
possible. Original code was in Matlab and had all of the data within the
script, so I took that out and stored in a separate data file for ease of
use.

Thanks for any suggestions.

Lester

Backstrip_1D_v1.sce
  
A1-NC198.csv   
Backstrip_1D_filled-plot.jpg
  



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Int3D / Triple integration

2021-04-02 Thread arctica1963
Quick query re: your code,

How is the index (i) defined?
i = [5 8 2 3
 5 8 2 6
 5 8 3 7
 5 2 3 1
 2 3 8 4]';

Just trying to fully understand your method.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Int3D / Triple integration

2021-04-02 Thread arctica1963
Hi Stephane,

Thanks for the information and methodology, useful to know. Learn something
new all the time with Scilab!

Kind regards

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Int3D / Triple integration

2021-04-02 Thread arctica1963
Hi Stephane,

At the moment I am just trying to understand how Scilab works with triple
integration of f(x,y,z) with limits for xyz. 

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Int3D / Triple integration

2021-04-02 Thread arctica1963
Hello all,

An update on a solution. Following e-mail correspondence with a fellow
Scilab user (Javier Domingo), he has worked out a general solution to
vectorising the X,Y,Z arrays for the tetrahedrons required by int3d. So
taking this part of the code and adding a call to int3d within a function we
get a simpler route to doing triple integrals given a function (f) and lower
and upper limits of integration defined by x1,x2,y1,y2,z1,z2:

function [Integral, Error] = Integral_3d (f, x1, x2, y1, y2, z1, z2)
// Divide prism (given by abscissa: x1, x2, ordinate: y1 to y2 and z1 to z2)
into
// 12 tetrahedra (not regular), starting from the center of the prism, cover
all its volume;
// providing the array IX (abscissa of the vertices of the triangles),
// and the array IY (ordinate of the vertices of the triangles).
   xc = (x1 + x2) / 2; yc = (y1 + y2) / 2; zc = (z1 + z2) / 2; // center of
prism
// coordinates of the prism tips (2 prisms on each face)
// bottom -top- right -left- front -rear-
   LX = [xc, xc, xc, xc, xc, xc, xc, xc, xc, xc, xc, xc;
   x1, x1, x1, x1, x2, x2, x1, x1, x1, x1, x1, x1;
   x2, x1, x2, x1, x2, x2, x1, x1, x2, x1, x2, x1;
   x2, x2, x2, x2, x2, x2, x1, x1, x2, x2, x2, x2];
   LY = [yc, yc, yc, yc, yc, yc, yc, yc, yc, yc, yc, yc;
   y1, y1, y1, y1, y1, y2, y1, y2, y1, y1, y2, y2;
   y1, y2, y1, y2, y2, y2, y2, y2, y1, y1, y2, y2;
   y2, y2, y2, y2, y1, y1, y1, y1, y1, y1, y2, y2];
   LZ = [zc, zc, zc, zc, zc, zc, zc, zc, zc, zc, zc, zc;
   z1, z1, z2, z2, z1, z2, z1, z2, z1, z1, z1, z1;
   z1, z1, z2, z2, z1, z1, z1, z1, z1, z2, z1, z2;
   z1, z1, z2, z2, z2, z2, z2, z2, z2, z2, z2, z2];
   
[Integral, Error] = int3d (LX, LY, LZ, f, 1, [0,10,1.d-5,1.d-7]);

endfunction

As a simple test one can define a function v=x^2 + y^2 + z^2 with limits of
0 to 1 - which simplifies to 1.0 as the sum of the iterated integrals.

deff('v=f(xyz,numfun)','v=xyz(1)^2+xyz(2)^2+xyz(3)^2')
x1=0;x2=1;y1=0;y2=1;z1=0;z2=1;

--> [Integral, Error] = Integral_3d (f, x1, x2, y1, y2, z1, z2)
 Integral  = 

   1.
 Error  = 

   1.110D-14

Thanks to Javier for his work on defining/clarifying the X,Y,Z arrays and
logic for defining the equation in Scilab. As a suggestion it would seem
reasonable to have this aspect either built into the function (int3d) or for
a separate mesh3d function to build tetrahedrons in a format compatible with
int3d.

Always great to exchange ideas to formulate a solution to a problem.

Code tested under Scilab version 6.1.0

Lester




--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Int3D / Triple integration

2021-03-25 Thread arctica1963
Hello,

Following on from a previous query I had on this matter, I am not having
much success with int3d for triple integration, largely due to the need to
build tetrahedrons. CGLab does have this option (delauney3d) but is not
available for 6.1.0, and it is not entirely clear how it would interface
with int3d.

Monte-Carlo integration is one route - located this online (added xmin xmax
etc):

function mcInt3d = intg3d(f,xmin,xmax,ymin,ymax,zmin,zmax,N) 
vol = (xmax-xmin)*(ymax-ymin)*(zmax-zmin) 
xr = (xmax-xmin)*rand(1,N)+xmin 
yr = (ymax-ymin)*rand(1,N)+ymin 
zr = (zmax-zmin)*rand(1,N)+zmin 
sumf= sum(f(xr,yr,zr))  
mcInt3d = vol*sumf/N 
endfunction

It does work but in order to get close to a good approximation, N needs to
be quite large. I am sure if we could get int3d to be more user friendly
that would be great.

More of a shout out to anyone who has used int3d using limits defined for
x,y,z and how to vectorise the tetrahedrons. Would love to be able to crack
this problem.

Thanks

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Scilab & cdf-file format

2021-02-12 Thread arctica1963
Hello

There is a toolbox for 5.5.2 called scinetcdf which will work - this will
work with the standard netCDF format. However, it will not work in version
6.x of Scilab. Perhaps a Scilab expert could look at how to get it compiled
for the latest Scilab?

Cheers

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Triple integral (int3d) query

2021-01-01 Thread arctica1963
Hi Samuel,

Many thanks for the suggestion. Happy New Year to you too.

Kind regards
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Triple integral (int3d) query

2021-01-01 Thread arctica1963
Hello all,

I have worked out a simpler input for 2D integration with a function that
calls int2d:

function [Integral, error]=Integral_2d(xmin,xmax,ymin,ymax,f)
X=[xmin xmax xmax; xmin xmax xmin]'
Y=[ymin ymin ymax; ymin ymax ymax]'
[Integral, error]=int2d(X,Y,f)
endfunction

This simplifies the issue for triangulation and only needs the x, y limits
and function to integrate; tested with the int2d example and works fine.

Is it feasible to use the same methodology for int3d - triple integral - for
defining the tetrahedron vertices? Really all one wants to do is enter the
limits of x, y and z, with a function f(x,y,z).

Any suggestions would be welcome

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problem with dos function

2020-12-20 Thread arctica1963
Same issue with console-only Scilab: Scilex,exe and WScilex-cli.exe.

For reference, GMT can be installed from
https://www.generic-mapping-tools.org/
Using Win64 version
https://github.com/GenericMappingTools/gmt/releases/tag/6.1.1

Lester





--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problem with dos function

2020-12-19 Thread arctica1963
HI Samuel,

Tried the unix_*() options with no success, redirect also did not work.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problem with dos function

2020-12-19 Thread arctica1963
Hi Samuel,

Tested with consolebox on and it is empty, so it's not sending data there.

As a test, I did a simple windows copy: dos('copy crop1.grd
crop1a.grd','-echo') and that worked, so no issue with basic windows
commands.

Not sure what else to try unless it's an installation issue?

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Problem with dos function

2020-12-18 Thread arctica1963
Hello Samuel,

Yes I did try the powershell option and it is the same response, the program
runs (boolean result is true) but the result is not resolved in the output.

The external program is using GMT (Generic mapping tools) and so that needs
to be installed to test this issue.

I also installed 5.4.1 to check and that also gives the same problem.

I checked the function in Octave (5.1.0) which looks the same as Scilab and
it gives the proper result:
https://octave.sourceforge.io/octave/function/dos.html

>> dos('grdinfo crop1.grd')
crop1.grd: Title: Grid computed with Mirone
crop1.grd: Command:
crop1.grd: Remark: File written from Matlab
crop1.grd: Gridline node registration used [Geographic grid]
crop1.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
crop1.grd: x_min: 1.058 x_max: 5.1416667 x_inc: 0.01667
(1 min) name: longitude n_columns: 24
6
crop1.grd: y_min: 3.8416667 y_max: 7.908 y_inc: 0.01667
(1 min) name: latitude n_rows: 245
crop1.grd: z_min: -106.033233643 z_max: 131.578842163 name: z [unknown]
crop1.grd: scale_factor: 1 add_offset: 0
crop1.grd: format: netCDF-4 chunk_size: 246,245 shuffle: on deflation_level:
8

ans = 0

I have looked at the Octave file, but it uses a "system" function which is
not the same in Scilab:

function [status, text] = dos (command, echo_arg)

  if (nargin < 1 || nargin > 2)
print_usage ();
  endif

  status = 1;
  text = "";

  ## FIXME: Should this be ispc ()?  There may be an issue with MinGW
  if (! isunix ())
[status, text] = system (command);
if (nargin > 1 || nargout == 0)
  printf ("%s\n", text);
endif
  endif

endfunction

Where is the dos function in Scilab? 

Not sure if it is relevant, but testing on Windows 8.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Problem with dos function

2020-12-17 Thread arctica1963
Hello,

I have an issue with the dos function for running an external program;
tested in 5.5.2 and 6.1.0 with same result:

--> [s,bOK]=dos('grdinfo crop1.grd')
 s  = 

[]
 bOK  = 

  T

The result of grdinfo is empty and should give the following if typed at the
command prompt:

D:\Geoscience\Scilab>grdinfo crop1.grd
crop1.grd: Title: Grid computed with Mirone
crop1.grd: Command:
crop1.grd: Remark: File written from Matlab
crop1.grd: Gridline node registration used [Geographic grid]
crop1.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
crop1.grd: x_min: 1.058 x_max: 5.1416667 x_inc: 0.01667
(1 min) name: longitude n_columns: 246
crop1.grd: y_min: 3.8416667 y_max: 7.908 y_inc: 0.01667
(1 min) name: latitude n_rows: 245
crop1.grd: z_min: -106.033233643 z_max: 131.578842163 name: z [unknown]
crop1.grd: scale_factor: 1 add_offset: 0
crop1.grd: format: netCDF-4 chunk_size: 246,245 shuffle: on deflation_level:
8

However, dos('dir','-echo') works and list the directory! Is there a bug or
a missing option to apply? In an earlier version (5.4.1) it worked fine.

Thanks

Lester








--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] {EXT} Re: Multiple regression on semi-log plot

2020-11-19 Thread arctica1963
Hello,

Just a quick thought. But could a moving window over the wavenumber provide
a simpler route to locating the kink points for computing the slope
segments? Perhaps a window size of say 0.05 and shifted 0.025 with the
existing methodology you outlined Stephane.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Multiple regression on semi-log plot

2020-11-16 Thread arctica1963
Hello,

Thanks for showing how it works, always good to get a proper understanding.

Just wondering if the code can be adapted to find multiple straight line
segments? Looking at my original test data, it appears to have "kinks" at
wavenumber (0.05, 0.12 and 0.16), the last one is where the x plots. I am
guessing that it needs some threshold or tolerance control as the angles at
the kink points may be small or larger.

Many thanks for the guidance.
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Multiple regression on semi-log plot

2020-11-14 Thread arctica1963
Hello,

Thanks for the idea and suggestions. Not too sure how to apply it, if you
could give some pointers on the attached data and code. The ultimate idea is
to get the slopes of the straight line segments. Many thanks, Lester

clear
clf()
// Read data - wavelength (in km)), power, 1 standard deviation
// Unknown data length; 3 columns -default space delimited

// PSD_wavelength.dat from GMT grdfft radially averaged power spectra

data = read('PSD_wavelength.dat',-1,3);

wavelength = data(:,1);
power = data(:,2);
std_dev1 = data(:,3);

ln_power = log(power);

wavenumber = 1./wavelength;
f=gcf();

//plot(wavenumber, ln_power)

scatter(wavenumber, ln_power,'marker','.')

a=gce().children;
a.mark_mode = "on"
a.mark_style = 0
a.mark_size_unit = "point"
a.mark_size=3

xlabel ('wavenumber k (km-1)')
ylabel ('Log (Power)')

PSD_wavelength.dat
  



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Multiple regression on semi-log plot

2020-11-09 Thread arctica1963
Hello,

I am looking to determine multiple regression lines from a single power
spectral dataset (log power vs radial wavenumber), and was wondering if it
is feasible in Scilab to compute something similar to the attached plot?

I did locate a Matlab code for finding a turning point in a plot and perhaps
this may be a route to find the change in curvature?

clear
clf()
//to find the "knee"
dt = 0.01;
t = 0:dt:1;
y = exp(-10*t);
//Compute first and second derivatives by finite differencing (centred)
//yp = nan(size(y));
//ypp = nan(size(y));
yp=%nan*y; // similar behaviour to Matlab nan(size(y))
ypp=%nan*y;
yp(2:$-1) = (y(3:$) - y(1:$-2))/(2*dt); // first derivative
ypp(2:$-1) = (y(3:$) + y(1:$-2) - 2*y(2:$-1)) / (dt^2); // second derivative
//Compute the curvature
k = abs(ypp) ./ (1 + yp.^2).^1.5
//Find the maximum curvature point and plot it on the curve
[kmax, idx] = max(k);
plot(t, y, 'b', t(idx), y(idx), 'ro')
//plot the curvature
figure()
plot(t, k)

Any pointers or ideas would be welcome.

Thanks
Lester


 



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Random colours for plot markers

2020-06-28 Thread arctica1963
Thanks Samuel. Always good to learn different methods.



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Random colours for plot markers

2020-06-27 Thread arctica1963
Thanks Rafael,

That is a good solution. Would be nice if that was available directly in
Polarplot

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Random colours for plot markers

2020-06-27 Thread arctica1963
Hello,

I would like to generate random colours for the markers in a polar plot (for
example), but not sure what is needed.

adding:  f.color_map = rand(jetcolormap(64));  will give random colours for
each new plot, but what I would like to try is to randomise the colours of
the markers. In the following script, the polar plot generates point markers
but all red, is it possible to plot with random colours?

clear
clf()
// Enter the upper range
x = input("Enter the upper range : ");
angle=180/%pi;
p=primes(x);
rad=p;
theta=p*angle;

f = gcf();
f.figure_size=[1024,1024];
a=gca();
a.tight_limits=["on", "on"]
a.mark_mode="on"
a.mark_style=0
a.mark_size_unit="point"
a.mark_size=3
a.mark_foreground = 21 // <- sets the current marker colour from figure
properties

// plot the prime number in  polar coordinates
polarplot(theta,rad,style=0)

Thanks for any pointers
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Polar plot query

2020-03-20 Thread arctica1963
Many thanks!



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Polar plot query

2020-03-20 Thread arctica1963
Hi all,

Very basic query. I have a polar plot and I want to just have the data
points visible but not the graticule of the polar plot. I have the figure
defined as f=gcf() with axes a=gca().

Is there a quick way to just turn it off? According to the figure properties
it is all under the Axes property with the graticule represented by arc,
segs and text, with the data points/symbols as a compound element.

Sorry for a really basic question! I am sure it is very obvious.

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Line integrals

2020-02-25 Thread arctica1963
Hello all,

I am interested in doing line integrals on f(x,y) and f(x,y,z) for scalar
and vector calculations.

It is not an issue to do mathematically, but not so clear in Scilab how
variable substitution should work in this process. As I understand it, one
has to take the function and convert it to a parametric form in x,y,(z) in
order to reduce the integrand to a single variable (e.g. t) that can be
integrated simply.

Now, clearly it is not a problem to do the substitutions by hand and then
run the Scilab function (Integrate), but nice to simplify the procedure.

For the integral over a path (C) of f(x,y) ds, x and y have to be parametric
e.g. x(t) and y(t),
where ds = sqrt( (dx(t)/dt)^2 + (dy(t)/dt)^2 ) dt

Is there a simple route to solve line integrals in Scilab or building a
function to do this? 
e.g. LineIntegral(expr,x(t),y(t),t,a,b), where x(t) and y(t) are the
parametric forms.

A very simple problem:

f(x,y) = 2*x with x(t)=t/2 and y(t)=t^2 for t=0 to 6
Substitution for x and y and solving the integral over t should result in
144.36 approx.

Any pointers would be useful. Could not see any reference in the mailing
list or help on this.

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] 2D Density plot

2020-02-13 Thread arctica1963
Hello all,

I was wondering if it is possible to generate a 2D density plot from
scattered data to highlight areas with a higher concentration of points
compared to others?

 

The image shows a subsidence plot with theoretical curves and real data
overlaid. It would be nice to have a way to colour the density of points,
but leave areas with zero density blank. 

In GIS software (e.g. ArcMap or QGIS) this would be defined using a
"Heatmap" based on a search radius around each data point.

Any ideas?
Thanks




--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= ?==?utf-8?q? e

2020-02-12 Thread arctica1963
PI250KDP.TXT   
PI500KDP.TXT   

clear
// path to the txt file
path = 'PI250KDP.txt'
// read the file as string
piAsString = csvRead(path, [],[],'string')
// split the string at '' (use no token) 
[piAsString] = strsplit(piAsString,'');
// convert string to double
piDigits = strtod(piAsString);
// search: how often appears a certain value in a specific range within the
digits
searchRange = 1;
searchVal = 1;
// adapt the range, to search only places behind the decimal sign
[locations] = find(piDigits(1:searchRange+1) == searchVal); // small tweak
here
printf("The number %d appears %d times in the first %d digits of
Pi\n",searchVal,length(locations),searchRange) ;
printf("The number %d appears at following locations: \n", searchVal);
disp(locations');

The 250K file works; the 500k file fails



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= =?utf-8?q? [EXTERNAL] Count specific values in text file

2020-02-12 Thread arctica1963
Hello Antoine

I am using version 6.0.2. Not sure if it is the same issue as there is only
one line in the file, but a lot of digits to handle. The error message is
not exactly clear.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] [EXTERNAL] Count specific values in text file

2020-02-12 Thread arctica1963
Hi Philipp,

Your script works fine using csvRead.

One odd thing. Tested a few files with pi, and ones with >= 500,000 gave an
error:

csvRead: can not read file pi-million.txt: Error in the column structure. 
(same for 500,000), but worked with 250,000? Not sure if this an internal
bug/limit in csvRead.

Thanks for the pointers everyone

Lester 



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] [EXTERNAL] Count specific values in text file

2020-02-11 Thread arctica1963
Hello Philipp

Your suggestion is kind of what I am trying to do, but the text file is not
a CSV structure. It is just a single, very big number on one row. A small
chunk:

31415926535897932384626433832795028841971693993751058209749445923078164 etc
(no spaces between digits)

How best to load the text file and then count the number of occurrences of a
specific digit (e.g. 1)? At the moment the file essentially contains a very
big integer.

Interested to see the best method of doing this.

Thanks 





--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Count specific values in text file

2020-02-11 Thread arctica1963
Hello all,

Basic query. I have text files of Pi and e to a million places and I want to
scan the number for the occurrences of particular values and the separation
of those values in the number.

This code snippet works on a vector:

// create vector of elements

A=[1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 4 4 5 5 5 5 8 8];

// Count number of values, e.g. 1

Val_count1= sum(A==1)

disp(Val_count1) // answer 7

I can open the text file with pinum=mopen('pi-million.txt','rt') - but does
it need to be changed to a vector where each value is an element?. At the
moment the text file is just a single line of numbers (no decimal pint at
the start (e.g. 314159...etc).

Any pointers would be good. Sorry if this is basic one!

Thanks



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Double and triple integral query

2020-01-31 Thread arctica1963
Thanks for the update Samuel.

Have added a bug/feature request related to the user input issue:

Scilab bugzilla: #16309

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] SciNetCDF for Scilab 6.x

2018-08-11 Thread arctica1963
Thanks for looking in to this, sorry can't be more help. As I understand,
Scilab does support the gcc compiler and it clearly recognises it as
present.

At least I have a way of using GMT grids via a function to read ESR Ascii
raster for now. Not convenient for large data files!

Cheers
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] SciNetCDF for Scilab 6.x

2018-08-10 Thread arctica1963
Got a gcc compiler installed (MingW) and checked that Scilab sees it

The compiler failed after a load of messages:

!Makelib:127: recipe for target 'libscinetcdf_hl.dll' failed  !
! !
!make: *** [libscinetcdf_hl.dll] Error 1  !
at line25 of function dlwCompile   (
C:\Users\x\AppData\Roaming\
Scilab\SCILAB~1.1\atoms\x64\mingw\010~1.5\macros\windows\dlwCompile.sci line
34
)
at line70 of function ilib_compile ( C:\Program
Files\scilab-6.0.1\m
odules\dynamic_link\macros\ilib_compile.sci line 86 )
at line   104 of function ilib_for_link( C:\Program
Files\scilab-6.0.1\m
odules\dynamic_link\macros\ilib_for_link.sci line 118 )
at line29 of function tbx_build_src( C:\Program
Files\scilab-6.0.1\m
odules\modules_manager\macros\tbx_build_src.sci line 44 )
at line35 of function builder_c(
D:\Geophysics\Scilab\netcdf4-ma
ster\netcdf4-master\src\c\builder_c.sce line 35 )
at line34 of executed file
D:\Geophysics\Scilab\netcdf4-master\netcdf4-maste
r\src\c\builder_c.sce
at line13 of function tbx_builder  ( C:\Program
Files\scilab-6.0.1\m
odules\modules_manager\macros\tbx_builder.sci line 26 )
at line60 of function tbx_builder_src_lang ( C:\Program
Files\scilab-6.0.1\m
odules\modules_manager\macros\tbx_builder_src_lang.sci line 75 )
at line 4 of function builder_src  (
D:\Geophysics\Scilab\netcdf4-ma
ster\netcdf4-master\src\builder_src.sce line 6 )
at line-4 of executed file
D:\Geophysics\Scilab\netcdf4-master\netcdf4-maste
r\src\builder_src.sce
at line13 of function tbx_builder  ( C:\Program
Files\scilab-6.0.1\m
odules\modules_manager\macros\tbx_builder.sci line 26 )
at line44 of function tbx_builder_src  ( C:\Program
Files\scilab-6.0.1\m
odules\modules_manager\macros\tbx_builder_src.sci line 61 )
at line29 of function main_builder (
D:\Geophysics\Scilab\netcdf4-ma
ster\netcdf4-master\builder.sce line 37 )
at line50 of executed file
D:\Geophysics\Scilab\netcdf4-master\netcdf4-maste
r\builder.sce

ilib_compile: Error while executing Makelib.

Not an expert on C++ so not sure what needs tweaking? 



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] SciNetCDF for Scilab 6.x

2018-08-10 Thread arctica1963
Quick update.

Tried the build, but it needs a C or Fortran compiler:

--> exec builder.sce

--> // Copyright (C) 2008 - INRIA

--> // Copyright (C) 2009-2011 - DIGITEO


--> // This file is released under the 3-clause BSD license. See
COPYING-BSD.


--> mode(-1);
Building macros...
-- Creation of [scinetcdflib] (Macros) --
genlib: Processing file: array2mat.sci
genlib: Processing file: deleteArray.sci
genlib: Processing file: getArrayTypeName.sci
genlib: Processing file: getSciNetCDFPath.sci
genlib: Processing file: mat2array.sci
genlib: Processing file: ncdisp.sci
genlib: Processing file: ncgen.sci
genlib: Processing file: newArray.sci
at line27 of function tbx_builder_src ( C:\Program
Files\scilab-6.0.1\modules\modules_manager\macros tbx_builder_src.sci line
44 )
at line29 of function main_builder(
D:\Geophysics\Scilab\netcdf4-master\netcdf4-master\builder.sce line 37 )
at line50 of executed file
D:\Geophysics\Scilab\netcdf4-master\netcdf4-master\builder.sce

tbx_builder_src: This module requires a C or Fortran compiler and it has not
been found.
-->

Any suggestions would be great.



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] SciNetCDF for Scilab 6.x

2018-08-10 Thread arctica1963
Thanks Ekin!

Will have a go at this and see how I get on.

Cheers



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] SciNetCDF for Scilab 6.x

2018-08-08 Thread arctica1963
Hello,

Just a quick query. Are there plans to get scinetcdf to work on Scilab 6.x?
The existing version (1.2) is not compatible, but does work under 5.5.2

More a question to Simon Marchetto (package maintainer).

Not sure if there is a way to manually get it working in Scilab 6.0.1

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-08-04 Thread arctica1963
As a general point, anyone know when the SciNetCdf package will be updated
for 6.0.1 ?

It fails to run/install on 6.0.1 because it references an older library (for
use in 5.5.2).



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Moving window over 2D grid

2018-08-03 Thread arctica1963
Hi Rafael,

At the moment I am just looking to get a general methodology/script to test.
The real data grid is more like 1500x1500 or more. 

The function could be anything really (e.g. z=f(x,y)), but ultimately I am
looking to run a radial averaged PSD from which one can extract depth to
magnetic sources (that's another story as they say!). 

Not sure if that is any clearer. As I say, just looking for a general
structure to test, before jumping ahead.

I'm guessing it needs a nested for loop for rows and columns?






--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Moving window over 2D grid

2018-08-03 Thread arctica1963
Hello all,

I know this topic has been touched on before:

Efficient calculation for a moving window

  

I am looking at running a moving window over a grid, incrementally shifting
along rows and columns, to allow processing within a window, with output
appended to a file (e.g. some mathematical function)

Can the code below be adapted for such processing:

// START OF CODE
n = 100;
m = 20; // moving window size

function y=f(x)
// function f can be anything but must operate on columns of input x
y = mean(x,'c');  
endfunction

// Initial loop solution:
y = rand(1,n);
y1 = zeros(1,n-m+1);
for i=1:n-m+1
y1(i)=f(y(i:i-1+m));
end

// Optimized solution with vectorization:
[X,Y] = meshgrid(1:m,1:n-m+1);
y2 = f(matrix(y(X+Y-1),n-m+1,m));

printf("difference = %g\n",norm(y1-y2'))

// END OF CODE

I have a grid with has nx_cols=120 and ny_rows=120, and I want to run say a
10x10 window, shifting 5 units (rows and columns for overlaps) over the
whole grid and calculate within each window. I am assuming that one has to
do this via indexing rows and columns respectively. Hopefully this can be
clarified.

Sorry if this is a very basic query!

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Padding and clipping a grid

2018-08-03 Thread arctica1963
Hi Rafael,

Forgot to say, the source code is available for all of the GMT modules, as
log as you understand C++

I just found reference to detrending prior to fft, thanks for confirming
that process! 

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-08-03 Thread arctica1963
Hello Ekin,

The scinetcdf package is not available compiled for Windows v6.0.1 (yet). It
does work for 5.5.x to install. Reading and writing the ascii raster is a
workaround until it is avialable (and working) under 6.x.

Thanks for the info

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Padding and clipping a grid

2018-08-02 Thread arctica1963
Hi Rafael,

I reviewed the methodology applied in GMT (grdfft) and they use tapering
from the grid edges to zero. The documentation page details more:

GMT_grdfft   

The padding method that has been discussed previously is the similar to that
of grdfft edge-point symmetry, but without the tapering to zero. 

It would be handy to have this padding and tapering better defined in Scilab
for 2D grids.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Padding and clipping a grid

2018-07-29 Thread arctica1963
Thanks for the suggestions and clarification.





--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Padding and clipping a grid

2018-07-29 Thread arctica1963
Hi all,

I will have to look further into this. I can check the results against GMT
(grdfft), I think they may use tapering but will have to look at the code
(C++).

Can I confirm that clipping is done via resize_matrix?

Cheers
Lester





--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Padding and clipping a grid

2018-07-29 Thread arctica1963
Hello all,

I need to increase the dimensions over which the FFT is calculated to avoid
edge effects, and following the suggestion of Samuel Gougeon back in 2016,
this was recommended:

Scilab: 6.0.1

data = [1 2 3; 4 5 6; 7 8 9]
addedRows = 3; addedCols = 3;

tmp = [data ; data($, :) .*. ones(addedRows, 1)]; // add rows to bottom
tmp = [tmp  tmp(:, $) .*. ones(1,addedCols)]; // add columns to right
tmp = [repmat(tmp(1, : ), addedRows, 1) ; tmp]; // add rows to top
paddedMat = [repmat(tmp(:,1) , 1, addedCols) tmp] // add columns to left

Now, it is important to adjust the input spatial limits (e.g. degrees) for
the new grid:

e.g. x1 = -1, x2 = 1, y1 = -1, y2 = 1 original spatial limits

pad = 1 // add 1 unit to all edges
x1a = x1 - pad 
x2a = x2 + pad 
y1a = y1 - pad 
y2a = y2 + pad 

xx1a = linspace(x1a,x2a,new_xdim)
yy1a = linspace(y1a,y2a,new_ydim)

[X,Y] = meshgrid(xx1a,yy1a) etc.

What I would like to do is then run the FFT on the expanded grid and then
clip it back to the original dimensions (before padding) and spatial limits
after processing.

Is there a simple solution to this? I was thinking
resize_matrix(data,dimx,dimy), but not sure how to get the original grid
clipped out. So in the example above, go from the padded limits (-2,2,-2,2)
back to (-1,1,-1,1).

Sorry if this is a really simple solution, still learning!

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] FFT - upward continuation of a 2D grid

2018-07-28 Thread arctica1963
Hi Rafael,

Problem solved with your guidance! The cellsize was in decimal degrees, so
converted to linear units 0.01 degrees = 1850m approx.

//dxy = 0.01666; decimal degrees - 1 arc minute
dxy = 1850;
dkx=1/(nx*dxy);
dky=1/(ny*dxy);

...

fft_clean=clean(fft2(Boug_corr));
k=fftshift(k);

Fup=fft_clean.*exp(-2*%pi*k*uc); // needed to be angular k

F_real=real(ifft(Fup));

fftshift was applied wrong, so thanks for spotting that!

All I need to do to finish this is pad the grid, run the fft, and clip it
back to the original size. A rough check of the output compared to that from
GMT is minor

Thanks again!



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] FFT - upward continuation of a 2D grid

2018-07-28 Thread arctica1963
Hi Rafael,

Thanks for the pointers. Still having some issues getting it to work on real
data. Upward continuation, should act like a low-pass and give a smoother
view of the data.

dimx=size(xt);
dimy=size(yt);

nx=dimx(1);
ny=dimy(1);

dxy = 0.01666;
dkx=1/(nx*dxy);
dky=1/(ny*dxy);

kx=dkx*(-(nx/2)+1:nx/2);
ky=dky*(-(ny/2)+1:ny/2);

[KX,KY]=meshgrid(kx,ky);
k=sqrt(KX.^2 + KY.^2);

uc=4000; // continue up 4000m

//fft_Boug_corr=fft2(Boug_corr);
//shift_f=fftshift(fft_Boug_corr); 
//fft_clean=clean(shift_f);

fft_clean=clean(fftshift(fft2(Boug_corr))); // merge commands

Fup=fft_clean.*exp(-k*uc);

F_real=real(ifft(Fup)); 

It does generate output, but certainly not as expected for upward
continuation of data. Not sure what I'm missing, assuming I have done the
wavenumber thing correct. Normally I would do this via GMT, but want to get
it going under Scilab for convenience.

Clearly, before doing a proper fft, we need to pad the data to expand the
dimensions over which the fft is done to avoid edge effects. Just running it
with the grid dimensions should still produce a recognisable result.

Matbe testing with a synthetic grid would help.

Cheers
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] FFT - upward continuation of a 2D grid

2018-07-26 Thread arctica1963
Hello all,

A quick query regarding fft and wavenumber calculations. I am looking to do
an upward contuation of a gravity data grid using fft and the basic
equation:

fft_Grav_up = fft2(gravity_input) * e^(-kz) // think it also needs fftshif
to centre Zero?

... Upward_continued_gravity=ifft(fft_out_Grav_up)

Where z = upward continuation distance and k = wavenumber

k =sqrt(kx^2 + ky^2)

Is there an easy way to get the wavenumber from the input?

Before doing the fft, the grid would need padding on all edges, so I think
this works unless there is a better method:

dimx=size(xt)
dimy=size(yt)

// For FFT pad X,Y to 2*ncols, 2*nrows (large enough to avoid boundary
effects)

addedRows = dimy(1); addedCols = dimx(1);

tmp = [Boug_corr; Boug_corr($, :).*.ones(addedRows, 1)];
tmp = [tmp  tmp(:, $).*.ones(1,addedCols)];
tmp = [repmat(tmp(1, :), addedRows, 1) ; tmp];
Boug_corr_padded = [repmat(tmp(:,1), 1, addedCols) tmp]

After running fft, the grid would then be clipped back to the correct size.

If there is a simple code for doing this great!

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-07-26 Thread arctica1963
Hi all,

Just a quick update. Used a function to import an ESRI ascii raster seems to
work ok:

function [X,Y,Z]=asc_2_xyz(filename)

fd=mopen(filename,'r'); // open ascii raster for read only
k=mfscanf(fd,'%s\t%d'); nc=k(2); // number of columns
k=mfscanf(fd,'%s\t%d'); nr=k(2); // number of rows
k=mfscanf(fd,'%s\t%f'); x1=k(2); // X coordinate = lower left
k=mfscanf(fd,'%s\t%f'); y1=k(2); // Y coordinate = lower left
k=mfscanf(fd,'%s\t%f'); dxy=k(2); // X and Y increment
k=mfscanf(fd,'%s\t%f'); nodata=k(2); // No data value (e.g. -)
mclose(fd)

// x1 and y1 = minimum X and Y

x2 = x1+dxy*nc; // Define maximum X coordinate
y2 = y1+dxy*nr; // Define maximum Y coordinate

Z=fscanfMat(filename); // Z matrix
Z(Z==nodata)=%nan; // if any 'nodata' values in grid set to internal NaN
value
Z=flipdim(Z,1); // for some reason the data are flipped on Y on import
so needed flipping

xx=linspace(x1,x2,nc); // same number of columns but increment different
from dxy
yy=linspace(y1,y2,nr);
[X,Y]=meshgrid(xx,yy); // Coordinate matrices

endfunction

All looks fine, but the increment from linspace cannot match dxy unless one
has nc+1. Not a big issue as this can be corrected in GMT. But also reversed
the thing to output .asc and that gets all the dimensions and increment
fine:

function xyz_2_asc(filename,X,Y,Z,nodata,n)
// n = precision (e.g. 6)
// nodata should be appropriate for the Z data range
//e.g. xyz_2_asc(test.asc,x,y,z,-,6)

// Define matrix dimensions
dimx=size(X); // 2-D
dimy=size(Y);
dimz=size(Z);

// Grid properties
minx=min(X); //initial X coordinate (Lower left)
maxx=max(X);
miny=min(Y); //initial Y coordinate (Lower left)
maxy=max(Y);

dxy=abs(maxx-minx)/dimx(1) // correct for increment precision issues

// Z matrix
Z(isnan(Z))=nodata; // add nan values (where present)) to output file
Z=flipdim(Z,1); // invert matrix rows in Y

// Output file

fd=mopen(filename,'w'); // open file for write
// Create ESRI Ascii raster header
//
// ncols 120
// nrows 120
// xllcorner -5
// yllcorner -5
// cellsize 0.01667 - must be square pixels for ESRI ascii raster
// nodata_value - (select value appropriate for dataset)
//
mfprintf(fd,'ncols\t');
mfprintf(fd,'%d\n',dimz(2));
mfprintf(fd,'nrows\t');
mfprintf(fd,'%d\n',dimz(1));
mfprintf(fd,'xllcorner\t');
mfprintf(fd,'%f\n',minx);
mfprintf(fd,'yllcorner\t');
mfprintf(fd,'%f\n',miny);
mfprintf(fd,'cellsize\t');
mfprintf(fd,'%.10f\n',dxy); // rounding errors > %.10f but not critical
to output
mfprintf(fd,'NODATA_value\t');
mfprintf(fd,%f\n',nodata);

// write Z values to file   

for i=1:dimz(1)
for j=1:dimz(2)
if j==dimz(2)
mfprintf(fd,'%f\n',Z(i,j));
else
mfprintf(fd,'%f\t',Z(i,j));
end
end
end
mclose(fd);

endfunction

Ideally, it would be good to work out a way of reading the binary netCDF
grids, much smaller size, but at least it seems to work albeit a bit quirky
with the increments and flipping!

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-07-22 Thread arctica1963
Thanks for the ideas, I will check the new builds and see what happens.



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-07-22 Thread arctica1963
Hello,

I am looking to use netCDF files generated from the GMT software in Scilab
6.0.1, but there is no easy way to work the problem other than exporting the
data out from the binary grids to either XYZ or ESRI Ascii raster. The
latter is a more compact form with the basic structure of a header
describing the data limits and structure:

ncols 1200 
nrows 1200
xllcorner -10 Lower-left X (Long-Lat limits -10/10/-10/10
yllcorner -10 Lower-Left Y
cellsize 0.01667 - increment = 1 arc minute
nodata_value -
451.343170166   436.005554199   443.061035156   443.665924072   465.607574463
492.191741943   476.50994873452.265014648   451.439880371   461.659393311   
..
...
... all of the Z-values
...

-4323.2890625   -4315.12451172  -4307.19384766  -4305.27490234  -4311.49902344
-4317.90771484  -4324.23046875  -4320.47070313  -4308.60107422  -4292.62011719
-4280.39697266

This is a moderately large file ~20 mB or so. Is there a way to reliably
read this structure and vectorise X, Y, and Z? The data I am looking at is a
grid so want to work on the whole grid as eith DEM data or gravity etc.

As a test, I converted the grid to xyz, and tried csvRead, having replaced
the spaces (which were not a constant number of spaces between values) with
commas. The file was in excess of 50 mb, so not that huge really, but
csvRead always failed to read all the file and drop out at one specific line
(~7608) with a message of inconsistent column numbers, i.e. it though there
were only 2 columns when in reality the whole thing was 3 (checked in the
program Surfer). When one looks at the line specified, it is clearly 3
columns.

Does csvRead have a limit to what it can load, if so what is a workaround? I
suppose one could chop it down into chunks and concatanate the arrays, but
that is a lot more work.

Any suggestions?

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Getting netCDF files into Scilab 6.0.1

2018-07-22 Thread arctica1963
Hello,

I am looking to use netCDF files generated from the GMT software in Scilab
6.0.1, but there is no easy way to work the problem other than exporting the
data out from the binary grids to either XYZ or ESRI Ascii raster. The
latter is a more compact form with the basic structure of a header
describing the data limits and structure:

ncols 1200 
nrows 1200
xllcorner -10 Lower-left X (Long-Lat limits -10/10/-10/10
yllcorner -10 Lower-Left Y
cellsize 0.01667 - increment = 1 arc minute
nodata_value -
451.343170166   436.005554199   443.061035156   443.665924072   465.607574463
492.191741943   476.50994873452.265014648   451.439880371   461.659393311   
..
...
... all of the Z-values
...

-4323.2890625   -4315.12451172  -4307.19384766  -4305.27490234  -4311.49902344
-4317.90771484  -4324.23046875  -4320.47070313  -4308.60107422  -4292.62011719
-4280.39697266

This is a moderately large file ~20 mB or so. Is there a way to reliably
read this structure and vectorise X, Y, and Z? The data I am looking at is a
grid so want to work on the whole grid as eith DEM data or gravity etc.

As a test, I converted the grid to xyz, and tried csvRead, having replaced
the spaces (which were not a constant number of spaces between values) with
commas. The file was in excess of 50 mb, so not that huge really, but
csvRead always failed to read all the file and drop out at one specific line
(~7608) with a message of inconsistent column numbers, i.e. it though there
were only 2 columns when in reality the whole thing was 3 (checked in the
program Surfer). When one looks at the line specified, it is clearly 3
columns.

Does csvRead have a limit to what it can load, if so what is a workaround? I
suppose one could chop it down into chunks and concatanate the arrays, but
that is a lot more work.

Any suggestions?

Thanks
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ATOMS error (Scilab 6.0.1)

2018-07-22 Thread arctica1963
Thanks for the update.



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] ATOMS error (Scilab 6.0.1)

2018-07-21 Thread arctica1963
Hello all,

Just recently been getting this error when running the ATOMS module manager:

"No ATOMS module is available. Please, check your Internet connection or
make sure that your OS is compatible with ATOMS."

I am using version 6.0.1 and know that it was working a while back, so not
sure what has changed. It can clearly get to the repository to update the
database, but then generates an error. Console shows: "Scanning repository
http://atoms.scilab.org/6.0 ... Done"

I also verified this on a separate machine that I only recently updated with
6.0.1, and that gave the same response. Not a big deal as I tend to write
functions as I need them, but seems odd. 

Tried deleting the user folder at:
C:\Users\\AppData\Roaming\Scilab\scilab-6.0.1 but did not help.

Any ideas? It works fine under 5.5.2.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Transparency for 3D surfaces

2018-06-21 Thread arctica1963
Hello all,

A very general query, but are there plans to include transparency options to
3D (and 2D) plots/surfaces? I have seen this discussed previously with
reference to 5.3.x and 5.5.2; it would certainly be useful for surface
plots. 

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Compute normals to 3D surface

2018-06-18 Thread arctica1963
Thanks Stéphane, Rafael for all your help. All helps with the learning
process.
Cheers
Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Compute normals to 3D surface

2018-06-18 Thread arctica1963
Hi Rafael,

Xarrows() worked to generate the normals in  Scilab 6.0.1.

 

Getting closer to the solution, but it gets "confused" at position (x=1.5,
y=0, z=0) where the vectors should change to inbound rather than outbound as
the surface folds as shown in the illustrative figure before. At this point
we actually see a double vector. From x=0 to -1 it should be on the "inner"
part if I'm looking at this right?

Is it possible to just show the vector arrows along say z=0 only? Hopefully
I am explaining this properly.

Thanks for the help, very informative.

Lester



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users