Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline ndtma  
#1 Posted : 06 July 2019 08:51:39(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
On the request of a fellow Engineer, the attached SM program was developed
to find the Standardized Precipitation Index (SPI).
58 years of daily precipitation data was available.

The SPI is widely used to analyze meteorological drought on a range of
time scales. There are proprietary software packages for this purpose.

The “vectorize” function was pretty handy and fast in analyzing various conditions.

Vectorize function.png

SPI_cal-Rev & Improved-Final.sm (1,968kb) downloaded 115 time(s).
Rainfal_Data.xlsx (487kb) downloaded 81 time(s).

Edited by user 06 July 2019 09:02:29(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 3 users thanked ndtma for this useful post.
on 06/07/2019(UTC),  on 06/07/2019(UTC),  on 06/07/2019(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline ndtma  
#2 Posted : 19 September 2019 18:23:07(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Attached file may be useful in handling data, where it may be
necessary to extract numerical values removing any strings, or
negative values, zeros etc.

Data Analysis Using Truth Table.sm (79kb) downloaded 48 time(s).

DataAnalysis_Results.png

DataAnalysis_Cond.png

Edited by user 19 September 2019 18:26:27(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Jean Giraud  
#3 Posted : 19 September 2019 18:44:46(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: ndtma Go to Quoted Post
Attached file may be useful in handling data, where it may be
necessary to extract numerical values removing any strings, or
negative values, zeros etc.

Maybe more or otherwise in there.

Utilities Matrix Truth Table.sm (60kb) downloaded 52 time(s).
Utilities Matrix Truth Table [UNSORTED alyles].sm (16kb) downloaded 44 time(s).
Utilities Matrix Truth Table [Locate row_col].sm (44kb) downloaded 53 time(s).
Offline ndtma  
#4 Posted : 13 April 2020 19:20:47(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Advantage of vectorize function revisited.
Another practical example attached, with extensive use of the vectorize function. No loops used.
Comments by Martin, Jean, Razonar and others on this subject much appreciated.
Hope this may be useful for beginners.
Cheers

Vect_Augment.PNG
SPI_cal-Millawana_Multiple_R5.sm (179kb) downloaded 43 time(s).
rainfall_KalaOyaBAsin.xlsx (586kb) downloaded 29 time(s).

Edited by user 13 April 2020 19:23:18(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Jean Giraud  
#5 Posted : 13 April 2020 19:47:05(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: ndtma Go to Quoted Post
Comments by Martin, Jean, Razonar and others on this subject much appreciated.

Sorry mon Ami ... SS 6179 does not open ... Jean
Offline ndtma  
#6 Posted : 13 April 2020 20:04:20(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Sorry. PDF attached.

SPI_cal-Millawana_Multiple_R5.pdf (1,058kb) downloaded 62 time(s).
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 2 users thanked ndtma for this useful post.
on 14/04/2020(UTC),  on 14/04/2020(UTC)
Offline Jean Giraud  
#7 Posted : 14 April 2020 15:04:19(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Thanks for the *.PDF ... superb quality !
Offline ndtma  
#8 Posted : 12 November 2020 09:56:59(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
I have found this useful in day to day work.
Data imported from MS Excel sheet, and using "findrows" function to sum daily data to monthly totals.

Vect_Grouping.png

Edited by user 12 November 2020 10:29:53(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 12/11/2020(UTC)
Offline ndtma  
#9 Posted : 16 November 2020 20:13:48(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.

Handling DATE STRINGS.sm (17kb) downloaded 25 time(s).

DATE_Strings.png

Edited by user 16 November 2020 20:23:55(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 17/11/2020(UTC)
Offline Jean Giraud  
#10 Posted : 17 November 2020 02:48:19(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
The secret is inside your nice piece of work ... superb, thanks.
Take care my Friend ... Jean
Offline Razonar  
#11 Posted : 17 November 2020 05:58:06(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: ndtma Go to Quoted Post
Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.


Hi. Handling data strings you have also this cheat for convert dates to numeric matrices.

Handling DATE STRINGS.sm (21kb) downloaded 25 time(s).

Clipboard01.jpg

Best regards.
Alvaro.
thanks 2 users thanked Razonar for this useful post.
on 17/11/2020(UTC),  on 18/11/2020(UTC)
Offline ndtma  
#12 Posted : 17 November 2020 07:41:25(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Thank you Jean for your kind words and encouragements. Take care.

Thank you Razonar for the superb alternative. Take care.
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Jean Giraud  
#13 Posted : 17 November 2020 15:44:04(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
You too Alvaro: take care, thanks ... Jean
Offline ndtma  
#14 Posted : 02 February 2021 10:35:43(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 124 time(s) in 82 post(s)
Originally Posted by: ndtma Go to Quoted Post
Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.

Revised program to handle date strings.

Handling DATE STRINGS+Alvaro.sm (44kb) downloaded 20 time(s).
String2Num.png
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 02/02/2021(UTC)
Offline Jean Giraud  
#15 Posted : 02 February 2021 17:27:50(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: ndtma Go to Quoted Post
Revised program to handle date strings.

Thanks Collab for that most useful work.
Saved ... for future use.
Cheers ... Jean

Offline Razonar  
#16 Posted : 02 February 2021 21:44:06(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: ndtma Go to Quoted Post
Attached is a simplified version of a project work for demonstration only.


Hi Amarasekera. Yes, that one, thanks. The fact you're showing despite to me about the speed in procedures with arrays. In the attached some comments about the need to redefining M:=M where M is a matrix argument in a procedure.

Clipboard01.jpg

EvalTest.sm (18kb) downloaded 19 time(s).

EvalTest.pdf (74kb) downloaded 11 time(s).

Best regards.
Alvaro.

thanks 1 user thanked Razonar for this useful post.
on 03/02/2021(UTC)
Offline Jean Giraud  
#17 Posted : 03 February 2021 00:53:27(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Your last Speedy Gonzalez is the Smath Numerical Fairy.
As it looks, pure numerical code coincidence as a fact.
Slightly adapted for convenience SS 6179
Thanks, cheers ... Jean

Maths eval(,) TEST.sm (17kb) downloaded 20 time(s).
Offline ElSid  
#18 Posted : 03 February 2021 01:26:52(UTC)
ElSid


Rank: Advanced Member

Groups: Registered
Joined: 05/03/2009(UTC)
Posts: 433
Man
United States
Location: USA

Was thanked: 17 time(s) in 15 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi Amarasekera. Yes, that one, thanks. The fact you're showing despite to me about the speed in procedures with arrays. In the attached some comments about the need to redefining M:=M where M is a matrix argument in a procedure.
Best regards.
Alvaro.

Alvaro,
Are you showing that by redefining Mo variable, within the program, it speeds it up 30 fold? That makes no sense Wallbash
The only thing that remotely comes to mind is that M, being defined within the program structure as M:=Mo, is not having to read for the variable from the outside.
Have you, or anyone else, tried this on other programs?
Offline Razonar  
#19 Posted : 03 February 2021 01:54:30(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: ElSid Go to Quoted Post

Alvaro,
Are you showing that by redefining Mo variable, within the program, it speeds it up 30 fold? That makes no sense Wallbash


Yes. Please, try to check in your environment if this is true also. (Notice that my laptop is very slow, because always is running something else or overloaded by some other procedures)

Originally Posted by: ElSid Go to Quoted Post

Have you, or anyone else, tried this on other programs?


Yes. For this was the issue in the original Amarasekera work, and why I say that he was the first showing this behavior. But I have other codes where using M:=M speed up slow procedures. Actually anything with a loop over a matrix.

Here intermediate timing result, which I can't explain

Clipboard01.jpg

Best regards.
Offline Jean Giraud  
#20 Posted : 03 February 2021 04:13:47(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: ElSid Go to Quoted Post
The only thing that remotely comes to mind is that M, being defined within the program structure as M:=Mo, is not having to read for the variable from the outside.
Have you, or anyone else, tried this on other programs?

What's wrong or incorrect in there is length it shouldn't exist in Smath

EvenFaster.PNG
Users browsing this topic
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.