passaH2O / dorado

For shallow-water Lagrangian particle routing.
https://passah2o.github.io/dorado
MIT License
54 stars 9 forks source link

Minor tweaks #26

Closed elbeejay closed 3 years ago

elbeejay commented 3 years ago

PR does 7 minor things

  1. Switches "warnings" in particle_track.py from strings printed to the console to proper Python warnings, also augments existing tests to ensure these warnings are called and the text in the warning is what is expected.
  2. Instead of printing the iteration warning when a particle hits the ceiling for iterations (10,000) for a certain target time for each particle being routed, we collect the indices of the particles that hit that limit and then print a single warning at the end of the run_iteration call which provides the number of particles in this category and their indices.
  3. Basically do this same thing for the exposure_time as well so the printing is reduced to a single statement as opposed to one for each particle that do not leave the ROI.
  4. In plot_exposure_time() just add the if-statement to make save_output work as intended
  5. Adds seed_time as an optional parameter to the particle generation function, if set to a value other than 0 a warning will be raised to remind the user to use caution when post-processing as some (or all) travel times have been shifted some amount. Some tests added and updated to check behavior of function and ensure type-checking works.
  6. Minor linting/code-style changes to routines.py
  7. Adds self.verbose as an attribute of modelParams that gets passed to Particles, default is True meaning print statements and warnings are shown. Can be set to False and core Particles functions will not output anything to the console. Note, verbosity could also be modified on the fly by directly changing the Particles.verbose value, so if you wanted to run 1 iteration and check the warnings/print statements you could set it to True, and then turn it off be setting it to False for subsequent iterations.
wrightky commented 3 years ago

Yeah these are looking much cleaner so far. I do think now is a good time to add a verbose flag like Nelson suggested. We should probably also go ahead and add a seed_time to the particle generator while we have this open.

Will look into the border stuff rn to see what might be happening there.

elbeejay commented 3 years ago

Yeah these are looking much cleaner so far. I do think now is a good time to add a verbose flag like Nelson suggested. We should probably also go ahead and add a seed_time to the particle generator while we have this open.

Good idea, I added these to the PR

wrightky commented 3 years ago

Sorry for leaving this open for so long, it escaped my mind. All of these changes look good to me and I don't really have anything to add. I didn't find anything off about the way we handle the border in unstruct2grid or otherwise, so I think maybe the cell_type raster was being overwritten locally or something. Regardless, it looks like those issues resolved themselves somewhat.

Going to merge this so I can update my local codes, might have some interesting developments on improving runtimes after some testing. Will let you know soon.