HydrologicEngineeringCenter / Vortex

data processing utilities
MIT License
26 stars 7 forks source link

Error converting Grib2 to DSS using vortex scripts #59

Closed tharunpalla closed 2 years ago

tharunpalla commented 2 years ago

Hi,

I am trying to convert grib2 rainfall data to DSS format. I have written a script to fetch the grib2 files from 'https://nomads.ncep.noaa.gov/cgi-bin/filter_nam_conusnest.pl?dir=%2Fnam.20220204' and then used vortex to convert to DSS files.

I am currently getting the following error:

image

Attaching my code to fetch and convert to DSS files.

grib2_to_dss_convertor.txt get_current_data.txt

tombrauer commented 2 years ago

@tharunpalla Did you test importing a sample file using the vortex user interface prior to attempting to script?

tharunpalla commented 2 years ago

@tharunpalla Did you test importing a sample file using the vortex user interface prior to attempting to script?

Yes, I had imported using the interface prior running through script.

tombrauer commented 2 years ago

If the user interface works, and the script does not, there is likely an issue with your script. Can you upload a sample of your data?

danhamill commented 2 years ago

Just looking over the script you used to call importer one issue potential issue I see is how you encoded the path to your clip shape.

clip_shp = 'C:\Users\chand\Downloads\HEC_DSS_Automation\Vortex\examples\src\main\jython\boundary.shp'

I would try again with either the the path encoded as a raw string or using unix-like path separators.

clip_shp = r'C:\Users\chand\Downloads\HEC_DSS_Automation\Vortex\examples\src\main\jython\boundary.shp'
#or
clip_shp = 'C:\\Users\\chand\\Downloads\\HEC_DSS_Automation\\Vortex\\examples\\src\\main\\jython\\boundary.shp'
#or
clip_shp = 'C:/Users/chand/Downloads/HEC_DSS_Automation/Vortex/examples/src/main/jython/boundary.shp'

You could check to make sure all the file paths you are specifying are valid using os.path.exists before you call importer.

assert os.path.exists(clip_shp), "Cannot locate clipping shapefile"
tharunpalla commented 2 years ago

If the user interface works, and the script does not, there is likely an issue with your script. Can you upload a sample of your data?

Please find the grib2 files attached. I am trying to convert the attached grib2 to dss grib2.zip

tombrauer commented 2 years ago

@tharunpalla Can you test the file separator suggestion the @danhamill provided. This is a very common issue in Jython scripting.

tharunpalla commented 2 years ago

@tharunpalla Can you test the file separator suggestion the @danhamill provided. This is a very common issue in Jython scripting.

Hi @tombrauer and @danhamill, I have tried modifying the location string for shp file according to the suggestion but I am getting the same error.

Although, when I use a single variable as below

# variables = ['Total_precipitation_surface_1_Hour_Accumulation']

I get the output in the dss file. On contrary. If I use all the variables from the grib2 files, I get the error.

 variables = set()
    for file in files:
        vars = DataReader.getVariables(file)
        for s in vars:
            variables.add(str(s))
    variables = list(variables)
danhamill commented 2 years ago

I think that makes sense.

Since .grib2 are self-describing data, you would only need select one variable (if they are all the same type of data).

tharunpalla commented 2 years ago

Thanks for the clarification.

@danhamill @tombrauer I have one more query regarding the file conversion from grib2 to dss.

I want to convert a grib2 file which has precipitation data in UTC to DSS. I want to keep the time and date in the DSS into EST for the dss file using vortex. Could you please let me know if there is any way to change the timestamp in vortex?

I tried renaming the Grib2 files but the dss file remains same even after renaming.

danhamill commented 2 years ago

Have a look at the time_shifter utility.

tharunpalla commented 2 years ago

Thank you.