nasa / RHEAS

Regional Hydrologic Extremes Assessment System
MIT License
73 stars 54 forks source link

Ensemble sizes and assertion errors #37

Closed AdamJDuncan closed 8 years ago

AdamJDuncan commented 8 years ago

I've got CHIRPS & NCEP downloaded from 1981-1-1 for the LMB (Edit:LMR). Running forecasts on a single pixel before moving on. I've run nowcasts all the way through to ensure there is no missing data.

Here's my setup:

[forecast]
model: vic
startdate: 1995-1-1
enddate: 1995-3-1
basin: /media/adam/UbuData/RHEAS/RHEAS/data/PP_Bbox/FN_PP.shp
name: ForecastTest3
resolution: 0.25
ensemble size: 10
method: esp

[vic]
precip: chirps
temperature: ncep
wind: ncep
initialize: no
save to: db
save: soil_moist

Where FN_PP is a single pixel in Cambodia.

I know that there's nothing in the _writeForcing section of ensemble.py stating a maximum ensemble sizes, but I'm running into maximums. For example for 1995, an ensemble size of 5 will work, but 10 will return this:

Read meteorological forcing file
Model State Initialization
Running Model
Total Cumulative Water Error for Grid Cell = 0.0000
Total number of fallbacks in Tfoliage: 0
Total number of fallbacks in Tcanopy: 0
Total number of fallbacks in Tsnowsurf: 0
Total number of fallbacks in Tsurf: 0
Total number of fallbacks in soil T profile: 0
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
Traceback (most recent call last):
  File "./rheas", line 14, in <module>
    sys.exit(rheas.run())
  File "/media/adam/UbuData/RHEAS/RHEAS/src/rheas.py", line 83, in run
    forecast.execute(dbname, options)
  File "/media/adam/UbuData/RHEAS/RHEAS/src/forecast.py", line 92, in execute
    runVIC(dbname, options)
  File "/media/adam/UbuData/RHEAS/RHEAS/src/forecast.py", line 56, in runVIC
    models.writeForcings(method, options)
  File "/media/adam/UbuData/RHEAS/RHEAS/src/ensemble.py", line 138, in writeForcings
    self._ESP(options)
  File "/media/adam/UbuData/RHEAS/RHEAS/src/ensemble.py", line 207, in _ESP
    model.writeForcings(prec, tmax, tmin, wind)
  File "/media/adam/UbuData/RHEAS/RHEAS/src/vic/vic.py", line 382, in writeForcings
    tmin) == len(self.lat) * ndays and len(wind) == len(self.lat) * ndays
AssertionError

When I run the same but 1985-1-1 to 1985-3-1 (with a new schema name), an ensemble size of 10 WILL work! But when I run the exact same thing again, with a new schema name, I get the assertion error. Restarting/vacuuming the db fixes this.

So the max ensemble size appears to decrease the more data we're using... by 2010, the maximum is 3.

Commenting out the 'assert' in vic.py and running the above ini file gives this:

Read meteorological forcing file
Model State Initialization
Running Model
Total Cumulative Water Error for Grid Cell = 0.0000
Total number of fallbacks in Tfoliage: 0
Total number of fallbacks in Tcanopy: 0
Total number of fallbacks in Tsnowsurf: 0
Total number of fallbacks in Tsurf: 0
Total number of fallbacks in soil T profile: 0
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
writing data_11.125_104.125
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/media/adam/UbuData/RHEAS/RHEAS/bin/rheas in <module>()
     12 
     13 if __name__ == '__main__':
---> 14     sys.exit(rheas.run())

/media/adam/UbuData/RHEAS/RHEAS/src/rheas.pyc in run()
     81             nowcast.execute(dbname, options)
     82         if "forecast" in options:
---> 83             forecast.execute(dbname, options)
     84 
     85 

/media/adam/UbuData/RHEAS/RHEAS/src/forecast.pyc in execute(dbname, options)
     90         if 'vic' in forecast_options['model']:
     91             if 'vic' in options:
---> 92                 runVIC(dbname, options)
     93             else:
     94                 print "ERROR! No configuration options for VIC model."

/media/adam/UbuData/RHEAS/RHEAS/src/forecast.pyc in runVIC(dbname, options)
     54                           saveindb=True, saveto=saveto, saveargs=savevars)
     55     models.writeParamFiles()
---> 56     models.writeForcings(method, options)
     57     models.run(vicexe)
     58     models.setDates(startyear, startmonth, startday, endyear, endmonth, endday)

/media/adam/UbuData/RHEAS/RHEAS/src/ensemble.pyc in writeForcings(self, method, options)
    136         """Write forcings for the ensemble based on method (ESP, BCSD)."""
    137         if method.lower() == "esp":
--> 138             self._ESP(options)
    139         elif method.lower() == "bcsd":
    140             pass

/media/adam/UbuData/RHEAS/RHEAS/src/ensemble.pyc in _ESP(self, options)
    205             model.endyear, model.endmonth, model.endday = t.year, t.month, t.day
    206             prec, tmax, tmin, wind = model.getForcings(options['vic'])
--> 207             model.writeForcings(prec, tmax, tmin, wind)
    208         cur.close()
    209         db.close()

/media/adam/UbuData/RHEAS/RHEAS/src/vic/vic.pyc in writeForcings(self, prec, tmax, tmin, wind, lai)
    395                 print "writing " + filename
    396                 fout.write("{0:f} {1:.2f} {2:.2f} {3:.1f}\n".format(
--> 397                     prec[i][2], tmax[i][2], tmin[i][2], wind[i][2]))
    398             else:
    399                 fout.write("{0:f} {1:.2f} {2:.2f} {3:.1f}\n".format(

IndexError: list index out of range
LOG:  unexpected EOF on client connection with an open transaction

EDIT: When I run it on a 4x4 area the maximums remain the same, so it is forcing files per pixel, not total.

kandread commented 8 years ago

My guess is that when it resampled the years from climatology, it didn't have enough years to sample from for a larger ensemble size (hard to tell without testing it out with your particular setup). The a7a621073ac156f3d3a765616bf59139bb17b003 commit added code to repeat the list of available years if the ensemble size is larger. Can you try it and see if that fixes it? Thanks.

AdamJDuncan commented 8 years ago

OK I've tried 20 ensembles on a small tributary and it works. Thanks; closing.