HydrologicEngineeringCenter / Vortex

data processing utilities
MIT License
25 stars 7 forks source link

Jython docs for all tools (timeshifter, transposer, etc) #65

Open openSourcerer9000 opened 2 years ago

openSourcerer9000 commented 2 years ago

Good afternoon,

There is complete documentation on the Jython API for the Importer tool, and it appears some docs on sanitizer etc, but I would like to request a complete Jython API documentation for the rest of these tools.

It seems the whole functionality is exposed through Jython, and I'm able to dir() my way through one object at a time, but it's a tedious process without a roadmap.

openSourcerer9000 commented 2 years ago

This is the general pattern for time-shifter. Doc strings for each method will be helpful as well,

from mil.army.usace.hec.vortex.math import Shifter
from mil.army.usace.hec.vortex.io import DataReader

from java.time import Duration

inDSS = r'C:\in.dss'
outDSS = r'C:\out.dss'

shiftby = Duration.ofMinutes(30)
# All units options:
# https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#:~:text=the%20specified%20unit.-,static%20Duration,Obtains%20a%20Duration%20representing%20a%20number%20of%20seconds.,-static%20Duration

# find all pathnames:
sourceGrids = DataReader.getVariables(inDSS)

write_opts = {
    'partA': 'A_part',
    'partC': 'PRECIPITATION',
    'dataType': 'PER-CUM',
    'units': 'MM'
}

shifty = Shifter.Builder()\
    .pathToFile(inDSS)\
    .grids(sourceGrids)\
    .destination(outDSS)\
    .shift(shiftby)\
    .writeOptions(write_opts)\
    .build()

shifty.shift()