kmaterna / Strain_2D

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

read_multiple_strain_netcdfs() reads proper values from netcdfs, and then saves different values into xarray.DataSet #13

Closed kmaterna closed 2 years ago

kmaterna commented 2 years ago

Within this function, I tried several types of ds indexing: 1) assigning ds[method]=array on the fly; 2) saving data into a full dictionary before ds assignment; 3) xarray concat/merge functions; 4) deepcopy() stuff. Haven't fixed it yet. Early today I was getting grid #1 out of 4 read properly and 2-4 with mistakes. Later today I'm getting grid #3 and grid #4 out of 4 read properly and 1-2 with mistakes. I have no idea yet.

Most recent commit has my latest attempt, which is working for grids 3-4 out of 4. https://github.com/kmaterna/Strain_2D/commit/35aecfdd68dd81418393c4c481f41bbe40016d4f

Screen Shot 2021-09-27 at 9 47 43 AM
kmaterna commented 2 years ago

figured out the problem, but not yet the fix. The 4 input datasets each have slightly different values for ds.coords. Will have to go back and properly assess them at the netcdf writing stage to make sure they're the same. Upon reading into a dataset, it imposes the coords on the 2D grids globally, which cuts off parts of any array that doesn't match the first one. xarray.Dataset is very smart.

jlmaurer commented 2 years ago

Hey @kmaterna I've had a similar issue come up before when using xarray and the coordinates varying somewhat. Are there multiple places where the coordinate arrays are determined?

kmaterna commented 2 years ago

yeah, ds.coords can come from either of the gpsgridder_strain.nc, visr_strain.nc, tape_strain.nc, or huang_strain.nc files. I get slightly different results for each one. So this is a reminder for me to make sure the outputs of all techniques are very clean, and also make sure they're clean before building this comparison xarray.dataset.

kmaterna commented 2 years ago

@jlmaurer it works!! With all methods writing the same grid, the comparison works as intended. Go ahead and rebase.

kmaterna commented 2 years ago

Oh you beat me by 1 hour. I'll look into any potential merge issues.

jlmaurer commented 2 years ago

@kmaterna I think you should be fine and able to merge. I'll pull the latest changes and make sure it works on my end!