ROBelgium / MSNoise

A Python Package for Monitoring Seismic Velocity Changes using Ambient Seismic Noise | http://www.msnoise.org
European Union Public License 1.1
176 stars 83 forks source link

movstack single tuple bugfix #336

Closed asyates closed 7 months ago

asyates commented 7 months ago

PROBLEM:

Previously, when single tuple defined in list of tuples for mov_stacks, treated as single tuple e.g. (('1d','1d')) becomes ('1d','1d'), so

for mov_stack in mov_stacks:
                    mov_rolling, mov_sample = mov_stack

gives mov_rolling as '1' and mov_sample as 'd'. So conditional statement (if mov_rolling == mov_sample) not satisfied.

Similarly, error returned if len(mov_stack) > 2 in case of single tuple (e.g. if (('5min','30s')), mov_stack = '5min' and tries to unpack this into two variables).

FIX:

Checks to see if mov_stacks contains only single tuple, if so...wraps in another tuple. Now functions correctly

asyates commented 7 months ago

actually, need to adjust plotting codes with same fix. will do in later today:

e.g. plotting interferogram with tuple list (('3min','30s')) returning:

FILE DOES NOT EXIST: STACKS2/01/3_m/ZZ/SS.23699.SW_ss.23714.SW.nc

where mov_rolling = '3' and mov_sample = 'm'

ThomasLecocq commented 7 months ago

thanks for the bugfix! I'll wait for the plots' update before merging, then!

ThomasLecocq commented 7 months ago

maybe this should be in the API ? in get_params?

asyates commented 7 months ago

yup realised this myself when looking at some of the plotting codes, which makes the fix much simpler! just an issue of

if params.mov_stack.count(',') == 1:

in api not functioning as intended with tuples

ThomasLecocq commented 7 months ago

what are your swo & swp files that got committed too?

asyates commented 7 months ago

oops, yup i see, now removed in request.

ThomasLecocq commented 7 months ago

good to go, thanks!