Re: How to exit program with custom code and custom message?

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 15:28, Thomas Passin  wrote:
>
> On 3/13/2023 10:34 PM, scruel tao wrote:
> > Interesting, `raise SystemExit` seems to have the same behavior as 
> > `sys.exit`:
> >
> > ```shell
> > python -c "raise SystemExit(100)"
> > echo $?
> > <<< 100
> >
> > python -c " import sys; sys.exit(100)"
> > echo $?
> > <<< 100
>
> OTOH, you don't want to get too tricky:
>
> (on Windows, obviously)
> C:\Users\tom>py -c "import sys; sys.exit(type(100) == type('a'))"
>
> C:\Users\tom>echo %ERRORLEVEL%
> 0
>
> Presumably we wouldn't want to get an exit value of 0 for this case!
>

Why? You passed the value False, which is 0. So it should behave as
documented, and exit 0.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin

On 3/13/2023 10:34 PM, scruel tao wrote:

Interesting, `raise SystemExit` seems to have the same behavior as `sys.exit`:

```shell
python -c "raise SystemExit(100)"
echo $?
<<< 100

python -c " import sys; sys.exit(100)"
echo $?
<<< 100


OTOH, you don't want to get too tricky:

(on Windows, obviously)
C:\Users\tom>py -c "import sys; sys.exit(type(100) == type('a'))"

C:\Users\tom>echo %ERRORLEVEL%
0

Presumably we wouldn't want to get an exit value of 0 for this case!

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin

On 3/13/2023 11:50 PM, MRAB wrote:

On 2023-03-14 03:29, Thomas Passin wrote:

On 3/13/2023 10:34 PM, scruel tao wrote:

Lars:

I totally understand your reasoning here, but in some way it
follows the unix philosophy: Do only one thing, but do that good.



I understand, python is not strongly typed, so `sys.exit` will be
able to accept any types parameters rather than just integer. In
order to handle such “other” types logic, I think this function
already violated the unix philosophy, and there is no way to avoid
it.


Most Python folks will say the Python *is* fairly strongly typed, but
for a different definition of "type". That is, duck typing.

It's strongly typed but not statically typed, unless you count type 
hints, which are optional.


Yes, of course. That's pretty common knowledge.

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread MRAB

On 2023-03-14 03:29, Thomas Passin wrote:

On 3/13/2023 10:34 PM, scruel tao wrote:

Lars:

I totally understand your reasoning here, but in some way it
follows the unix philosophy: Do only one thing, but do that good.



I understand, python is not strongly typed, so `sys.exit` will be
able to accept any types parameters rather than just integer. In
order to handle such “other” types logic, I think this function
already violated the unix philosophy, and there is no way to avoid
it.


Most Python folks will say the Python *is* fairly strongly typed, but
for a different definition of "type". That is, duck typing.

It's strongly typed but not statically typed, unless you count type 
hints, which are optional.

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin

On 3/13/2023 10:34 PM, scruel tao wrote:

Lars:

I totally understand your reasoning here, but in some way it
follows the unix philosophy: Do only one thing, but do that good.



I understand, python is not strongly typed, so `sys.exit` will be
able to accept any types parameters rather than just integer. In
order to handle such “other” types logic, I think this function
already violated the unix philosophy, and there is no way to avoid
it.


Most Python folks will say the Python *is* fairly strongly typed, but 
for a different definition of "type". That is, duck typing.



--
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Lars:
> I totally understand your reasoning here, but in some way it follows the unix 
> philosophy: Do only one thing, but do that good.

I understand, python is not strongly typed, so `sys.exit` will be able to 
accept any types parameters rather than just integer.
In order to handle such “other” types logic, I think this function already 
violated the unix philosophy, and there is no way to avoid it.

Cameron:
> That kind of thing is an open ended can of worms. You're better off
> writing your own `aort()` function

Thank you for your advice and example, I applied such wrappers for many years, 
this question comes more from “pythonic” discussion, because as I mentioned 
above, `sys.exit` can accept any types.

> BTW, `sys.exit()` actually raises a `SystemExit` exception which is
> handled by the `sys.excepthook` callback which handles any exception
> which escapes from the programme uncaught.

Interesting, `raise SystemExit` seems to have the same behavior as `sys.exit`:

```shell
python -c "raise SystemExit(100)"
echo $?
<<< 100

python -c " import sys; sys.exit(100)"
echo $?
<<< 100

python -c "raise SystemExit('a’)"
<<< a
echo $?
<<< 1

python -c " import sys; sys.exit('a’)"
<<< a
echo $?
<<< 1

```

So, `sys.exit` is just a shortcut for `raise SystemExit`, or not? (Haven’t yet 
check the cpython source code)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread Thomas Passin

On 3/13/2023 9:47 PM, Chris Angelico wrote:

On Tue, 14 Mar 2023 at 12:38, Thomas Passin  wrote:


On 3/13/2023 9:07 PM, Chris Angelico wrote:

Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.

Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.


This is the kind of thing that unit tests can catch.



Maybe, but that's quite orthogonal. The linter would highlight the
exact line of code with the odd whitespace; a unit test would merely
point out that the overall behaviour is incorrect, which would have
been no further information beyond what the OP already knew (the
numbers weren't adding up).

ChrisA


*This* time the OP happened to know.  People in the thread have been 
discussing how to pick this kind of mistake with linters or what have 
you.  Even with a linter, whether or not this would have been picked up 
depends on how it has been configured.


Really, the only defense against these kind of potential mistakes or 
typos is not to use constructions that may be more likely to get wrong 
(or be typoed).  In this particular case, that would probably be too 
great a limitation for most of us.  But the general principle is a good 
one.  Douglas Crockford wrote a book on using just the better parts of 
Javascript (JavaScript: The Good Parts - rather dated by now but still 
worth the reading).


Of course, anyone can have a brain blip on any given day!

--
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 12:38, Thomas Passin  wrote:
>
> On 3/13/2023 9:07 PM, Chris Angelico wrote:
> > Of course, all this is predicated on you actually putting whitespace
> > around your equals signs. If you write it all crunched together as
> > "x=-5", there's no extra clues to work with.
> >
> > Linters and code reviewers can make use of all the available
> > information, including whitespace, to determine programmer intent.
>
> This is the kind of thing that unit tests can catch.
>

Maybe, but that's quite orthogonal. The linter would highlight the
exact line of code with the odd whitespace; a unit test would merely
point out that the overall behaviour is incorrect, which would have
been no further information beyond what the OP already knew (the
numbers weren't adding up).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread Thomas Passin

On 3/13/2023 9:07 PM, Chris Angelico wrote:

Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.

Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.


This is the kind of thing that unit tests can catch.

--
https://mail.python.org/mailman/listinfo/python-list


RE: =- and -= snag

2023-03-13 Thread avi.e.gross
Morten,

Suggesting something is UNPYTHONIC is really not an argument I take
seriously.

You wrote VALID code by the rules of the game and it is not a requirement
that it guesses at what you are trying to do and calls you an idiot!

More seriously, python lets you do some completely obscure things such as
check whether some random object or expression is truthy or not. There is no
way in hell the language, as defined, can catch all kinds of mistakes.

Now some languages or their linters have chosen to provide warnings of code
that may be valid but is often an error.

Consider:

  x  = 1
  y = 0
  x = y

Do I want to rest x to the value of y? Maybe. Or do I want the interpreter
to print out whether x == y perhaps?

Well what if the third line above was 

  x  == y

Is that too a warning? 

To add to the confusion some languages have an ===, :=, +=, -=, /=, |= or
oddities like %=% and many of these are all variations on meanings vaguely
related to equality before or after ...

So, no, it is not only not unpythonic, in my opinion, but quite pythonic to
let the interpreter interpret what you wrote and not know what you meant.

Is there possible a flag that would require your code to use spaces in many
places that might cut down on mistakes? There could be and so your example
of something like "new =- old" might be asked to be rewritten as "new = -
old" or even "new = (-old)" but for now, you may want to be more careful.

I do sympathize with the problem of a hard to find bug because it LOOKS
RIGHT to you. But it is what it is.

Avi

-Original Message-
From: Python-list  On
Behalf Of Morten W. Petersen
Sent: Monday, March 13, 2023 5:26 PM
To: python-list 
Subject: =- and -= snag

Hi.

I was working in Python today, and sat there scratching my head as the
numbers for calculations didn't add up.  It went into negative numbers,
when that shouldn't have been possible.

Turns out I had a very small typo, I had =- instead of -=.

Isn't it unpythonic to be able to make a mistake like that?

Regards,

Morten

-- 
I am https://leavingnorway.info
Videos at https://www.youtube.com/user/TheBlogologue
Twittering at http://twitter.com/blogologue
Blogging at http://blogologue.com
Playing music at https://soundcloud.com/morten-w-petersen
Also playing music and podcasting here:
http://www.mixcloud.com/morten-w-petersen/
On Google+ here https://plus.google.com/107781930037068750156
On Instagram at https://instagram.com/morphexx/
-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread MRAB

On 2023-03-14 00:28, Gary Herron wrote:


On 3/13/23 2:26 PM, morp...@gmail.com wrote:

Hi.

I was working in Python today, and sat there scratching my head as the
numbers for calculations didn't add up.  It went into negative numbers,
when that shouldn't have been possible.

Turns out I had a very small typo, I had =- instead of -=.

Isn't it unpythonic to be able to make a mistake like that?

Regards,

Morten



These all mean the same thing, but I don't see a good way to designate
the second or third as an error.


x = -5
x=-5
x =- 5

The third one could be picked up as suspicious by a linter due to its 
unusual spacing.

--
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 11:37, Gary Herron  wrote:
>
>
> On 3/13/23 2:26 PM, morp...@gmail.com wrote:
> > Hi.
> >
> > I was working in Python today, and sat there scratching my head as the
> > numbers for calculations didn't add up.  It went into negative numbers,
> > when that shouldn't have been possible.
> >
> > Turns out I had a very small typo, I had =- instead of -=.
> >
> > Isn't it unpythonic to be able to make a mistake like that?
> >
> > Regards,
> >
> > Morten
> >
>
> These all mean the same thing, but I don't see a good way to designate
> the second or third as an error.
>
>
> x = -5
> x=-5
> x =- 5
>

The second one isn't definitely an error, but the third is a failure
of style. Many style guides mandate, for instance, equal whitespace
either side of a binary operator. It's pretty straight-forward for a
program to tokenize your code the exact same way that Python would, so
it will interpret it thus:

NAME "x"
(whitespace " ")
OP "="
OP "-"
(whitespace " ")
NUMBER "5"

The whitespace parts aren't tokens in the normal sense, but worst
case, you can count positions. And since there's one space prior to
the "=" and none after, it violates the style rule, and can thus be
flagged.

(This is one reason that I detest autoformatters. You might notice the
autoformatter relayout your code into "x = -5", but if you don't spot
it right at that moment, there's a lower chance that it'll look like a
problem. OTOH, something that simply flags the error and leaves it for
you to fix, even if you don't notice it immediately, will bring this
line to your attention and let you wonder whether it's misformatted or
miscoded.)

Of course, all this is predicated on you actually putting whitespace
around your equals signs. If you write it all crunched together as
"x=-5", there's no extra clues to work with.

Linters and code reviewers can make use of all the available
information, including whitespace, to determine programmer intent.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: =- and -= snag

2023-03-13 Thread Gary Herron



On 3/13/23 2:26 PM, morp...@gmail.com wrote:

Hi.

I was working in Python today, and sat there scratching my head as the
numbers for calculations didn't add up.  It went into negative numbers,
when that shouldn't have been possible.

Turns out I had a very small typo, I had =- instead of -=.

Isn't it unpythonic to be able to make a mistake like that?

Regards,

Morten



These all mean the same thing, but I don't see a good way to designate 
the second or third as an error.



x = -5
x=-5
x =- 5


Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology

--
https://mail.python.org/mailman/listinfo/python-list


=- and -= snag

2023-03-13 Thread Morten W. Petersen
Hi.

I was working in Python today, and sat there scratching my head as the
numbers for calculations didn't add up.  It went into negative numbers,
when that shouldn't have been possible.

Turns out I had a very small typo, I had =- instead of -=.

Isn't it unpythonic to be able to make a mistake like that?

Regards,

Morten

-- 
I am https://leavingnorway.info
Videos at https://www.youtube.com/user/TheBlogologue
Twittering at http://twitter.com/blogologue
Blogging at http://blogologue.com
Playing music at https://soundcloud.com/morten-w-petersen
Also playing music and podcasting here:
http://www.mixcloud.com/morten-w-petersen/
On Google+ here https://plus.google.com/107781930037068750156
On Instagram at https://instagram.com/morphexx/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Monday, 13 March 2023 at 16:12:04 UTC+1, Thomas Passin wrote:
> On 3/13/2023 12:39 AM, a a wrote: 
> > But some unknown reasons Matplotlib and numpy crash my Python 3.8 for 
> > Windows , 32-bit and no support is offered
> It is possible, using pip, to downgrade versions (e.g., of Matplotlob 
> and numpy) to see if you can find versions that work. Of course moving 
> to 64-bit Python >= 3.10 would be better, but if that were possible I 
> imagine you would have done it already. 
> 
> BTW, it would be useful if you said what operating system you are using 
> (I've been assuming Windows).
sorry
Windows 7

My concept in building Earthquake Prediction System based on Precognition is
to use RTL Software Defined Radio (SDR) to receive data from outdoor seismic 
sensors (smartphones turned into seismographs - sending acceleration data via 
audio output, to be transmitted by radio transmitter to a remote RTL SDR 
station, for real time processing, P-wave energy envelope calculation, 
earthquake depth calculation sine in case of Turkey, USGS assigns 10km depth 
value by default to a single EQ event.

Why SDR ?
Since I don't expect Cellular network to work and be operational in remote, 
mountain regions of Turkey after the strong 7,8 earthquake, so SDR should work 
as backup for cellular 3G/LTE network in the region.

In case of Android smartphones I need to switch to Python for Android to get 
flexibility offered by scripting to support earthquake study ideas just in time 
and to share such ideas with friends.


---

python-for-android · PyPI
https://pypi.org/project/python-for-android

python-for-android is a packaging tool for Python apps on Android. You can 
create your own Python distribution including the modules and dependencies you 
want, and bundle it in an APK or AAB along with your own code. Features 
include: Different app backends including Kivy, PySDL2, and a WebView with Pyt… 
See more
Documentation

Follow the quickstartinstructionsto install and begin creating APKs and AABs. 
Quick instructions: install python-for-android with: (for the develop branch: 
pip install git+https://github.com/kivy/… See more
Contributing

We love pull requests and discussing novel ideas. Check out the Kivyproject 
contribution guideandfeel free to improve python-for-android. See ou… See more
Support

If you need assistance, you can ask for help on our mailing list: 1. User 
Group: https://groups.google.com/group/kivy-users 2. Email: 
kivy-us...@googlegroups.com … See more
History

In 2015 these tools were rewritten to provide a new, easier-to-use 
andeasier-to-extend interface. If you'd like to browse the old toolchain, 
itsstatus is re… See more
Explore further
Global web icon
Is there a way to run Python on Android? - Stack Overflow
stackoverflow.com
Global web icon
How to Download and Install Python for Android
mptricks.com
Global web icon
How to develop Android app completely using python?
stackoverflow.com
Global web icon
How to download and install Python Latest Version on An…
geeksforgeeks.org
Global web icon
An Introduction to Python for Android Development
pythonpool.com
Recommended to you based on what's popular • Feedback
From pypi.org
Content
Documentation
Support
Contributing
History
Create and run Python apps on your Android phone
https://opensource.com/article/20/8/python-android...

WebAug 26, 2020 · $ pkg install python Once the installation and auto set-up of 
configuration is complete, it’s time to build your application. Build an app 
for Android on Android Now that you have a terminal installed, you can …
GitHub - kivy/python-for-android: Turn your Python application …
https://github.com/kivy/python-for-android

Webpython-for-android is a packaging tool for Python apps on Android. You can 
create your own Python distribution including the modules and dependencies you 
want, and bundle it in an APK or AAB along with your …
When did Python 2 stop supporting Android?
See this and other topics on this result
An introduction to Python on Android - Android Authority
https://www.androidauthority.com/an-introduction...

WebMar 31, 2017 · Python is a particularly simple and elegant coding language 
that is designed with the beginner in mind. The problem is that learning to …

Reviews: 8

Estimated Reading Time: 9 mins

Android - Python Wiki
https://wiki.python.org/moin/Android

WebThere are several ways to use Python on Android. The following table 
summarizes those projects which are currently active: BeeWare is a toolkit for 
developing cross-platform …
People also ask
How to run Python on Android?Create and run Python apps on your Android phone 1 
Install Termux on Android. First, install the Termux application. ... 2 Build 
an app for Android on Android. Now that you have a terminal installed, you can 
work on your Android phone largely as if it were just another Linux computer. 3 
Write Python code on Android. You're all set up. ...
Create and run Python apps on your Android phone

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Monday, 13 March 2023 at 16:16:28 UTC+1, Thomas Passin wrote:
> On 3/13/2023 12:39 AM, a a wrote:
> > But what I need is analysis of seismograms from 4,000 seismographs world 
> > wide to detect P-wave energy distribution underground around the earthquake 
> > to verify EQ Domino Effect
> In that case, you will have to do a great deal of work to get all that 
> data into a common usable form, cleaned and errors removed. That will 
> be a lot of effort no matter what language you use. In the Matplotlib 
> lesson you pointed to, the work was already done, for one one earthquake 
> at one location. 
> 
> The reference I gave, 
> https://towardsdatascience.com/earthquake-time-series-forecasts-using-a-hybr 
> 
> id-clustering-lstm-approach-part-i-eda-6797b22aed8c 
> 
> actually includes a Python script that does this work for some selected 
> ranges of data, so it might be a good starting point.
Thank you
excellent example

"The imported json files were heavily-nested; hence, during data cleaning, I 
“denested” the json files, transformed them into dataframes, fixed the column 
datatypes, imputed the NaN values, and finally concatenated them into a global 
dataframe, which was workable. For a full description of data cleaning, visit 
my GitHub profile. Finally, I indexed the dataframe by timestamps as a 
time-series dataframe:

https://towardsdatascience.com/earthquake-time-series-forecasts-using-a-hybrid-clustering-lstm-approach-part-i-eda-6797b22aed8c


I would like to work with Saied Mighani one day but unfortunately, seismology 
projects, studies are one-man activity.

I am success oriented in building Earthquake Prediction System
and I am sure, P-wave energy envelope calculate for every earthquake, for every 
seismographic station can give valuable hints on how earthquake energy is 
distributed underground, since what is recorded by surface seismographs is some 
form of such P-wave envelope energy transferred at the direction of surface 
placed seismograph.

Ideas are great but life is for real ;)

thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 转发: How to exit program with custom code and custom message?

2023-03-13 Thread Cameron Simpson

On 13Mar2023 10:18, scruel tao  wrote:

Chris:

but for anything more complicated, just print and then exit.
It's worth noting, by the way, that sys.exit("error message") will
print that to STDERR, not to STDOUT, which mean that the equivalent
is:


Yes, I know, but don’t you think if `sys.exit` can take more parameters 
and have a default output channel selection strategy will be better?


That kind of thing is an open ended can of worms. You're better off 
writing your own `aort()` function such as:


def abort(message, *a, output=None, exit_code=1):
if a:
message = message %a
if output is None:
output = sys.stderr
print(message, file=output)
exit(exit_code)

which can be extended with whatever (potentially _many_) custom options 
you like. `sys.exit()` itself is just to abort your programme, and 
doesn't want a lot of knobs. The more knobs, the more things which have 
to be implemented, and if the knobs are not independent that gets 
complicated very quickly. Not to mention agreeing on what knobs to 
provide.


BTW, `sys.exit()` actually raises a `SystemExit` exception which is 
handled by the `sys.excepthook` callback which handles any exception 
which escapes from the programme uncaught.


Finally, in larger programs it is uncommon to call `sys.exit()` except 
in the very outermost "main function", and even there I tend to just 
`return`, myself. Example:


def main(argv=None):
if argv is None:
argv = sys.argv
xit = 0
 handle the command line arguments, run code ...
... errors set xit=1 or maybe xit="message" ...
return xit

if __name__ == '__main__':
sys.exit(main(sys.argv))

Notice that the only call to `sys.exit()` is right at the bottom.  
Everything else is just regularfunction returns.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


RE: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread avi.e.gross
Hi,

This seems again to be a topic wandering. Was the original question whether
Python could be used for dealing with Seismic data of some unspecified sort
as in PROCESSING it and now we are debating how to clean various aspects of
data and make things like data.frames and extract subsets for analysis?

Plenty of the above can be done in any number of places ranging from
languages like Python and R to databases and SQL. If the result you want to
analyze can then be written in a format with rows and columns containing the
usual suspects like numbers and text and dates and so on, then this part of
the job can be done anywhere you want.

And when you have assembled your data and now want to make a query to
generate a subset such as data in a date range that is from a set of
measuring stations and with other qualities, then you can simply save the
data to a file in whatever format, often something like a .CSV.

It is the following steps where you want to choose your language based on
what is available. Are you using features like a time series, for example?
Are you looking or periodicity. Is graphing a major aspect and do you need
some obscure graph types not easily found but that are parts of
packages/modules in some language like R or Python? Do you need the analysis
to have interactive aspects such as from a GUI, or a web page? Does any
aspect of your work include things like statistical analyses or machine
learning? The list goes on.

As mentioned, people who do lots of stuff along these lines can share some
tools in python, or elsewhere, they find useful and that might help fit the
needs of the OP but they work best when they have a better idea of what
exactly you want to do. Part of what I gleaned, was a want to do a 3-D graph
that rotates. Python has multiple graphics packages and so on as do
languages like R. The likelihood of finding something useful goes up if you
identify if there are communities of people doing similar work and can share
some of their tools. 

Hence the idea of focused searches. Asking here will largely get you people
mainly who use Python and if it turns out R or something entirely else meets
your needs better, perhaps Mathematica  even if you have to pay for it if
that is expected by your peers.

My guess is that python would be a decent choice as it can do almost
anything, but for practical purposes, you do not want to stick with what is
in the base and probably want to use extensions like numpy/pandas and
perhaps others like scipy and if doing graphics, there are too many
including matplotlib and seaborn but you may need something specialized for
your needs.

I cannot stress the importance of making sure the people evaluating and
using your work can handle it. Python is fairly mainstream and free enough
that it can foot your bill. But it has various versions and clearly nobody
would advise you to use version 2. Some versions are packaged with many of
the tools you may want to use, such as Anaconda. It depends on your level of
expertise already and how much you want to learn to get this task done. You
make it sound like your kind of work must be done alone, and that can
simplify things but also mean more work for you.

-Original Message-
From: Python-list  On
Behalf Of Thomas Passin
Sent: Monday, March 13, 2023 2:10 PM
To: python-list@python.org
Subject: Re: Can you process seismographic signals in Python or should I
switch to Matlab ?

On 3/13/2023 11:54 AM, Rich Shepard wrote:> On Mon, 13 Mar 2023, Thomas 
Passin wrote:
 >
 >> No doubt, depending on the data formats used. But it's still going
 >> to be a big task.
 >
 > Thomas,
 >
 > True, but once you have a dataframe with all the information about
 > all the earthquakes you can extract data for every analysis you want
 > to do.
This message would better have gone to the list instead of just me.

I'm not saying that Pandas is a bad choice!  I'm saying that getting all
that data into shape so that it can be ingested into a usable dataframe
will be a lot of hard work.

 > If you've not read Wes McKinney's "Python for Data Analysis: Data
 > Wrangling with Pandas, NumPy, and IPython" I encourage you to do so.

I've been interested in that title, but since I don't currently have any
large, complex data wrangling problems I've put it off.




-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin
On 3/13/2023 11:54 AM, Rich Shepard wrote:> On Mon, 13 Mar 2023, Thomas 
Passin wrote:

>
>> No doubt, depending on the data formats used. But it's still going
>> to be a big task.
>
> Thomas,
>
> True, but once you have a dataframe with all the information about
> all the earthquakes you can extract data for every analysis you want
> to do.
This message would better have gone to the list instead of just me.

I'm not saying that Pandas is a bad choice!  I'm saying that getting all
that data into shape so that it can be ingested into a usable dataframe
will be a lot of hard work.

> If you've not read Wes McKinney's "Python for Data Analysis: Data
> Wrangling with Pandas, NumPy, and IPython" I encourage you to do so.

I've been interested in that title, but since I don't currently have any
large, complex data wrangling problems I've put it off.




--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard

On Mon, 13 Mar 2023, Thomas Passin wrote:


No doubt, depending on the data formats used. But it's still going to be a
big task.


Thomas,

True, but once you have a dataframe with all the information about all the
earthquakes you can extract data for every analysis you want to do.

If you've not read Wes McKinney's "Python for Data Analysis: Data Wrangling
with Pandas, NumPy, and IPython" I encourage you to do so.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin

On 3/13/2023 11:23 AM, Rich Shepard wrote:

On Mon, 13 Mar 2023, Thomas Passin wrote:

But what I need is analysis of seismograms from 4,000 seismographs 
world wide to detect P-wave energy distribution underground around 
the earthquake to verify EQ Domino Effect



In that case, you will have to do a great deal of work to get all that
data into a common usable form, cleaned and errors removed. That will 
be a

lot of effort no matter what language you use. In the Matplotlib lesson
you pointed to, the work was already done, for one one earthquake at one
location.


Wouldn't Pandas help here?


No doubt, depending on the data formats used.  But it's still going to 
be a big task.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard

On Mon, 13 Mar 2023, Thomas Passin wrote:

But what I need is analysis of seismograms from 4,000 seismographs world 
wide to detect P-wave energy distribution underground around the earthquake 
to verify EQ Domino Effect



In that case, you will have to do a great deal of work to get all that
data into a common usable form, cleaned and errors removed. That will be a
lot of effort no matter what language you use. In the Matplotlib lesson
you pointed to, the work was already done, for one one earthquake at one
location.


Wouldn't Pandas help here?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin

On 3/13/2023 12:39 AM, a a wrote:

But what I need is analysis of seismograms from 4,000 seismographs world wide 
to detect P-wave energy distribution underground around the earthquake to 
verify EQ Domino Effect


In that case, you will have to do a great deal of work to get all that 
data into a common usable form, cleaned and errors removed.  That will 
be a lot of effort no matter what language you use.  In the Matplotlib 
lesson you pointed to, the work was already done, for one one earthquake 
at one location.


The reference I gave, 
https://towardsdatascience.com/earthquake-time-series-forecasts-using-a-hybr 


id-clustering-lstm-approach-part-i-eda-6797b22aed8c

actually includes a Python script that does this work for some selected 
ranges of data, so it might be a good starting point.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin

On 3/13/2023 12:39 AM, a a wrote:

But some unknown reasons Matplotlib and numpy crash my Python 3.8 for Windows , 
32-bit and no support is offered


It is possible, using pip, to downgrade versions (e.g., of Matplotlob 
and numpy) to see if you can find versions that work.  Of course moving 
to 64-bit Python >= 3.10 would be better, but if that were possible I 
imagine you would have done it already.


BTW, it would be useful if you said what operating system you are using 
(I've been assuming Windows).


--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Sunday, 12 March 2023 at 06:17:54 UTC+1, avi.e...@gmail.com wrote:
> I have used GNU Octave as a sort of replacement for MATLAB as a free 
> resource. I have no idea if it might meet your needs. 
> 
> Although Python is a good environment for many things, if you have no 
> knowledge of it yet, it can take a while to know enough and if you just need 
> it for one project, ...
> -Original Message- 
> From: Python-list  On 
> Behalf Of Thomas Passin 
> Sent: Sunday, March 12, 2023 12:02 AM 
> To: pytho...@python.org 
> Subject: Re: Can you process seismographic signals in Python or should I 
> switch to Matlab ?
> On 3/11/2023 6:54 PM, a a wrote: 
> > My project 
> > 
> https://www.mathworks.com/help/matlab/matlab_prog/loma-prieta-earthquake.htm 
> l 
> 
> If your goal is to step through this Matlab example, then clearly you 
> should use Matlab. If you do not have access to Matlab or cannot afford 
> it, then you would have to use something else, and Python would be a 
> prime candidate. However, each of the techniques and graphs in the 
> lesson have been pre-packaged for you in the Matlab case but not with 
> Python (many other case studies on various topics that use Python Python 
> can be found, though). 
> 
> Everything in the Matlab analysis can be done with Python and associated 
> libraries. You would have to learn various processing and graphing 
> techniques. You would also have to get the data from somewhere. It's 
> prepackaged for this analysis and you would have to figure out where to 
> get it. There is at least one Python package that can read and convert 
> Matlab files - I do not remember its name, though. 
> 
> A more important question is whether doing the Matlab example prepares 
> you to do any other analyses on your own. To shed some light on this, 
> here is a post on some rather more advanced analysis using data on the 
> same earthquake, done with Python tools - 
> 
> https://towardsdatascience.com/earthquake-time-series-forecasts-using-a-hybr 
> id-clustering-lstm-approach-part-i-eda-6797b22aed8c
> -- 
> https://mail.python.org/mailman/listinfo/python-list
Thank you my dear friends for your kind opinions.

Matlab is pro, commercial, paid and demo is available for tests only.
So it's hard to dicuss projects, apps in Matlab if cannot be verified by peers.

What is hot today is the following 3D plot animation in Matplotlib

https://twitter.com/gmrpetricca/status/1633477532526817281

But some unknown reasons Matplotlib and numpy crash my Python 3.8 for Windows , 
32-bit and no support is offered

Ok, I can read 100 research papers daily, preview hundreds pages of text from 
search engines.

But what I need is analysis of seismograms from 4,000 seismographs world wide 
to detect P-wave energy distribution underground around the earthquake to 
verify EQ Domino Effect

As you can see below, the Matlab project named in my first submission turned 
into Python project
and EQ energy envelope makes sense.

But I would prefer to join 100+ man project in seismology since it may take me 
months to download
seismograms, process seismograms, preview, select features and build EQ energy 
envelope 3D plots for earthquakes in Turkey alone.

To develop another theory, to get data, process data and get results for 
analysis to verify EQ energy envelope Domino Effect


I am afraid there are no team research projects in seismology.
What is published and discussed is one-man project.



PICOSS: Python Interface for the Classification of
Seismic Signals
A. Buenoa, L. Zuccarellob,c, A. D ́ıaz-Morenod, J. Woolamd, M. Titosb, L.
Garc ́ıaa, I.  ́Alvareza, J. Prudenciob, S. De Angelisd
aDepartment of Signal Theory, Telematic and Communications, University of 
Granada,
Spain.
bDepartment of Theoretical Physics and Cosmos, University of Granada, Spain.
cIstituto Nazionale di Geofisica e Vulcanologia, Sezione di Pisa, Italy
dDepartment of Earth, Ocean and Ecological Sciences, University of Liverpool, UK

https://core.ac.uk/download/pdf/334413225.pdf


seismic-signal 

https://github.com/topics/seismic-signal

STA-LTA Algorithm and Seismometer Trajectory visualization in 3D

Tonumoy /
STA-LTA-Algorithm-and-Seismometer-Trajectory-visualization-in-3D 


https://github.com/Tonumoy/STA-LTA-Algorithm-and-Seismometer-Trajectory-visualization-in-3D


PICOSS

A Python Interface for the Classification of Seismic Signals.

PICOSS is a Python GUI designed as a modular data-curator platform for 
volcano-seismic data analysis. Detection, segmentation and classification. With 
exportability and standardization at its core, users can select automatic or 
manual workflows to annotate seismic data from the suite of included tools.

Originally, PICOSS was designed for the purposes of seismicity research as a 
collaboration between University of Granada (UGR) and University of Liverpool 
(UoL). However, the system can be used within a wide range of geophysical 
applications.
We are currently working on switching 

Re: 转发: How to exit program with custom code and custom message?

2023-03-13 Thread Lars Liedtke

I totally understand your reasoning here, but in some way it follows the unix 
philosophy: Do only one thing, but do that good.

And exiting is something different from printing to STDOUT or STDERR. Yes 
sometimes you want to print something before exiting. But then you should do 
that explicitly and to the output you want and not implicitly rely on 
adfdtitional parameters of exit. Yes, not all functions work this way. But that 
does not mean they shouln't ;-)

Cheers

Lars

On 13.03.23 11:18, scruel tao wrote:

Chris:


It doesn't actually take a list of arguments; the square brackets


indicate that arg is optional here.

Oh, I see, it seems that I mistunderstood the document.



but for anything more complicated, just print and then exit.
It's worth noting, by the way, that sys.exit("error message") will
print that to STDERR, not to STDOUT, which mean that the equivalent
is:



Yes, I know, but don’t you think if `sys.exit` can take more parameters and 
have a default output channel selection strategy will be better?
Thanks.





Lars Liedtke
Software Entwickler

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail]l...@solute.de


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]


Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php



--
https://mail.python.org/mailman/listinfo/python-list


转发: How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Chris:
> It doesn't actually take a list of arguments; the square brackets
indicate that arg is optional here.

Oh, I see, it seems that I mistunderstood the document.

> but for anything more complicated, just print and then exit.
> It's worth noting, by the way, that sys.exit("error message") will
> print that to STDERR, not to STDOUT, which mean that the equivalent
> is:

Yes, I know, but don’t you think if `sys.exit` can take more parameters and 
have a default output channel selection strategy will be better?
Thanks.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to exit program with custom code and custom message?

2023-03-13 Thread Chris Angelico
On Mon, 13 Mar 2023 at 20:00, scruel tao  wrote:
>
> Currently, I use `sys.exit([arg])` for exiting program and it works fine.
> As described in the document:
> > If another type of object is passed, None is equivalent to passing zero, 
> > and any other object is printed to stderr and results in an exit code of 1.
>
> However, if I want to exit the program with status 0 (or any numbers else 
> except 1) and print necessary messages before exiting, I have to write:
> ```python
> print("message")
> sys.exit()
> ```
> So why `sys.exit` takes a list of arguments (`[arg]`) as its parameter? 
> Rather than something like `sys.exit(code:int=0, msg:str=None)`?

It doesn't actually take a list of arguments; the square brackets
indicate that arg is optional here. So you can either quickly print
out an error message and exit, or you can exit with any return code
you like, but for anything more complicated, just print and then exit.

It's worth noting, by the way, that sys.exit("error message") will
print that to STDERR, not to STDOUT, which mean that the equivalent
is:

print("error message", file=sys.stderr)
sys.exit(1)

Which is another reason to do things differently on success; if you're
returning 0, you most likely want your output on STDOUT.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Currently, I use `sys.exit([arg])` for exiting program and it works fine.
As described in the document:
> If another type of object is passed, None is equivalent to passing zero, and 
> any other object is printed to stderr and results in an exit code of 1.

However, if I want to exit the program with status 0 (or any numbers else 
except 1) and print necessary messages before exiting, I have to write:
```python
print("message")
sys.exit()
```
So why `sys.exit` takes a list of arguments (`[arg]`) as its parameter? Rather 
than something like `sys.exit(code:int=0, msg:str=None)`?
-- 
https://mail.python.org/mailman/listinfo/python-list