kmaterna / Strain_2D

Strain rate modeling from GNSS velocity fields
MIT License
43 stars 17 forks source link

VISR model parameters #18

Closed enrico-serpelloni closed 2 years ago

enrico-serpelloni commented 2 years ago

@kmaterna, thanks for this great project.

Actually only a few parameters of the VISR model cam be defined in the driver file:

distance_weighting = gaussian spatial_weighting = voronoi min_max_inc_smooth = 10/200/1

Another important one, the "weighting threshold", is only defined in strain_visr.py. Is it possible to have all parameters set in the configuration file?

Best, Enrico

kmaterna commented 2 years ago

Hi @enrico-serpelloni thanks for the message. And good to meet you - your nice work on vertical deformation in the Alps was something I read closely in grad school when I was coming up with possible new projects in Northern California.

Ah yes, it looks like I hard-coded the VISR weighting threshold and potentially other parameters for the purposes of my first project. That's a good suggestion. Thankfully, it should be simple - the config reader function doesn't need any changes; we just need to add the desired parameters the local config file and then unpack/use them in strain_visr.py.

Depending on your excitement about forks/PRs, do you want to actually make the changes on your own fork of the repo? That way you can make sure that it has all the parameters you're looking for. I actually think it could be done with only changing the strain_visr.py file -- "method_specific_dict" in line 32 is a dictionary that will take anything you placed in the [visr] part of your config, and then you can unpack it from there. If you do, I would love if you could contribute the changes on your fork back through a Pull Request. (My workflow is usually like "create personal Github fork - clone personal fork - make changes - test - commit to personal fork - make Github Pull Request - delete personal fork", but my collaborator Jeremy uses other ways too.)

I'm also very happy to make the changes myself; it should be simple and you can just use the updated repo when those are done.

What would be easiest for you?

Thanks! Kathryn

enrico-serpelloni commented 2 years ago

Hello @kmaterna. It would better for me if you can apply the changes (I am a beginner with GitHub and python). I was running Tape, Shen and GMT models independently on my data, before finding your code. I have been able to run Strain_2D with the example dataset (except that I am having an error in using GPSGRIDDER) and now I am trying with the Euro-Med velocity data. Thanks, Enrico

kmaterna commented 2 years ago

@enrico-serpelloni okay sounds good! I'll do it soon and let you know here when it's done. It's a slight rush before AGU right now but I will get to it within a few days. Thanks for the information!

kmaterna commented 2 years ago

@enrico-serpelloni ok I'm adding the parameters "weighting_threshold" and "uncertainty_threshold" to the config file. I'm not actually sure what uncertainty threshold does but I see it in one of my text files. I'm hard-coding "function=3" because we're always doing strain in this library, and I'm hard-coding the creeping fault parameters (number of creep faults = 0) for the moment because I've never used them before. Pull or clone again, and let me know if that works for you!

enrico-serpelloni commented 2 years ago

Hello @kmaterna. Sorry for the late replay. Yes, it works. Just remember to add in the "example_strain_config.txt" file the two additional raws:

weighting_threshold = 2 uncertainty_threshold = 0.05

I've run it on my velocity data and got the same results I had the same results I got running visr independently.

Instead, I am having problems with the gpsgridder option. It successfully computes the strain, so I guess it is a matter of strain-invariants computation or plotting:

Writing 2d outputs: writing human-readable velfile in station-vel format, Output/gpsgridder/tempgps.txt Computing strain invariants for 2d dataset. Traceback (most recent call last): File "/Users/enrico/opt/miniconda3/envs/Strain_2D/bin/strain_rate_compute.py", line 4, in import('pkg_resources').run_script('Strain-2D==1.0.0', 'strain_rate_compute.py') File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/pkg_resources/init.py", line 656, in run_script self.require(requires)[0].run_script(script_name, ns) File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/pkg_resources/init.py", line 1453, in run_script exec(code, namespace, namespace) File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/Strain_2D-1.0.0-py3.9.egg/EGG-INFO/scripts/strain_rate_compute.py", line 11, in internal_coordinator.strain_coordinator(MyParams); File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/Strain_2D-1.0.0-py3.9.egg/strain/internal_coordinator.py", line 27, in strain_coordinator output_manager.outputs_2d(Ve, Vn, rot, exx, exy, eyy, MyParams, velField); # 2D grid output format File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/Strain_2D-1.0.0-py3.9.egg/strain/output_manager.py", line 17, in outputs_2d ds = Dataset( File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/xarray/core/dataset.py", line 751, in init variables, coordnames, dims, indexes, = merge_data_and_coords( File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/xarray/core/merge.py", line 488, in merge_data_and_coords return merge_core( File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/xarray/core/merge.py", line 637, in merge_core collected = collect_variables_and_indexes(aligned) File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/xarray/core/merge.py", line 296, in collect_variables_and_indexes variable = as_variable(variable, name=name) File "/Users/enrico/opt/miniconda3/envs/Strain_2D/lib/python3.9/site-packages/xarray/core/variable.py", line 121, in as_variable raise TypeError( TypeError: Using a DataArray object to construct a variable is ambiguous, please extract the data using the .data property.

kmaterna commented 2 years ago

@enrico-serpelloni thank you for letting me know! After some digging, turns out we ran into a deprecation introduced in the xarray library several months ago. I reproduced the problem and then fixed it. Amazingly it was just a two-line fix. And thank you for the reminder about the example file. It should be fixed now, I hope.