NOAA-ORR-ERD / PyGnome

The General NOAA Operational Modeling Environment
https://gnome.orr.noaa.gov/doc/pygnome/index.html
Other
58 stars 44 forks source link

TAMOC test case #42

Open bhattvihang opened 6 years ago

bhattvihang commented 6 years ago

Hi,

I was trying to run the script_tamoc.py to test the tamoc - gnome coupling. However, I ended up with following error message. Can someone advise what is going on?

(gnome0.6) vihangs-MacBook-Pro:script_tamoc vihang$ ipython script_tamoc.py /Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/scipy/optimize/minpack.py:785: OptimizeWarning: Covariance of the parameters could not be estimated category=OptimizeWarning) images_dir is: /Users/vihang/pygnome0.6/PyGnome/py_gnome/scripts/script_tamoc/images removing... /Users/vihang/pygnome0.6/PyGnome/py_gnome/scripts/script_tamoc/images initializing the model adding the map adding outputters removed script_plume.nc adding Horizontal and Vertical diffusion adding Rise Velocity adding a circular current and eastward current Adding TAMOC spill about to start running the model Starting animation

ValueError Traceback (most recent call last) /Users/vihang/pygnome0.6/PyGnome/py_gnome/scripts/script_tamoc/script_tamoc.py in () 136 model = make_model() 137 print "about to start running the model" --> 138 for step in model: 139 print step['step_num'] 140 if step['step_num'] == 23:

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/model.pyc in next(self) 1011 :return: the step number 1012 ''' -> 1013 return self.step() 1014 1015 def full_run(self, rewind=True):

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/model.pyc in step(self) 972 # release particles for next step - these particles will be aged 973 # in the next step --> 974 num_released = sc.release_elements(self.time_step, self.model_time) 975 976 # initialize data - currently only weatherers do this so cycle

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/spill_container.pyc in release_elements(self, time_step, model_time) 889 # only spills that are included here - no need to check 890 # spill.on flag --> 891 num_rel = spill.num_elements_to_release(model_time, time_step) 892 if num_rel > 0: 893 # update 'spill_num' ArrayType's initial_value so it

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/tamoc/tamoc_spill.pyc in num_elements_to_release(self, current_time, time_step) 598 return 0 599 --> 600 self.droplets= self.run_tamoc(current_time, time_step) 601 602 duration = (self.end_release_time - self.release_time).total_seconds()

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/tamoc/tamoc_spill.pyc in run_tamoc(self, current_time, time_step) 333 if self.last_tamoc_time is None: 334 self.last_tamoc_time = current_time --> 335 self.droplets, self.diss_components = self._run_tamoc() 336 return self.droplets 337

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/tamoc/tamoc_spill.pyc in _run_tamoc(self) 393 depths = tp['depths'] 394 --> 395 profile = self.get_profile(nc_file, fname_ctd, ua, va, wa, depths) 396 397 # Get the release fluid composition

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/pyGnome-0.6.0-py2.7-macosx-10.9-x86_64.egg/gnome/tamoc/tamoc_spill.pyc in get_profile(self, nc_name, fname, u_a, v_a, w_a, depths) 755 P_data = np.vstack((data[:, 0], P)).transpose() 756 nc = ambient.fill_nc_db(nc, P_data, ['z', 'pressure'], ['m', 'Pa'], --> 757 ['average', 'computed'], 0) 758 759 # Create an ambient.Profile object from this dataset

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/tamoc/ambient.pyc in fill_nc_db(nc, data, var_symbols, var_units, comments, z_col) 1000 interp_data = np.zeros((z.shape[0],ny+1)) 1001 interp_data[:,z_col] = z[:] -> 1002 interp_data[:,y_cols] = f(z[:]).transpose() 1003 data = np.copy(interp_data) 1004

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/scipy/interpolate/polyint.pyc in call(self, x) 76 77 """ ---> 78 x, x_shape = self._prepare_x(x) 79 y = self._evaluate(x) 80 return self._finish_y(y, x_shape)

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/scipy/interpolate/polyint.pyc in _prepare_x(self, x) 88 def _prepare_x(self, x): 89 """Reshape input x array to 1-D""" ---> 90 x = _asarray_validated(x, check_finite=False, as_inexact=True) 91 x_shape = x.shape 92 return x.ravel(), x_shape

/Users/vihang/anaconda2/envs/gnome0.6/lib/python2.7/site-packages/scipy/_lib/_util.pyc in _asarray_validated(a, check_finite, sparse_ok, objects_ok, mask_ok, as_inexact) 234 if not mask_ok: 235 if np.ma.isMaskedArray(a): --> 236 raise ValueError('masked arrays are not supported') 237 toarray = np.asarray_chkfinite if check_finite else np.asarray 238 a = toarray(a)

ValueError: masked arrays are not supported

ChrisBarker-NOAA commented 6 years ago

@jay-hennen: is this script up to date?

May be time for a new version.

jay-hennen commented 6 years ago

Not 100% sure on the up-to-dateness of this, but it's scipy making the complaint this time. I've not seen this error before.

bhattvihang commented 6 years ago

UPDATE

Hi,

I was digging in the current issue. I am going line by line execution of the selected code, I found that on first call of nc = ambient.fill_nc_db(nc, data, names, units, comments, 0) the data for depth is stored as masked array instead of simple array.

_In [48]: nc.variables['z'][:] Out[48]: masked_array(data = [0.0 -- -- -- -- -- -- -- -- -- -- -- -- -- --], mask = [False True True True True True True True True True True True True True True], fillvalue = 9.96920996839e+36)

I am not sure why this occurs only for variable 'z'. When I retrieve other stored variables from from the file, all other appears to be normal array. This may be the root problem. I am still diagnosing the problem. However, if there is some expert advise, it will be very useful.

Regards,

Vihang Bhatt

bhattvihang commented 6 years ago

UPDATE

The problem was with tamoc/ambient.py

In order to resolve the issue, I had to go in to tamoc/ambient.py and change z.valid_max value It was 0 earlier. I changed it to z.valid_max=5000. I think any large number is valid as z_max is computed from CTD profile. My small subset to test the code works without any error.

Thanks for reading the problem.

Vihang Bhatt

bhattvihang commented 6 years ago

The script script_tamoc run successfully. However, the output is all zero. I am wondering why this happens. where the things go wrong. Can anyone advise if the coupling between TAMOC and GNOME successful?

The ncdump of the output file looks like this. why data is 0?

netcdf script_plume { dimensions: time = UNLIMITED ; // (37 currently) data = UNLIMITED ; // (0 currently) two = 2 ; three = 3 ; variables: double time(time) ; time:comment = "unspecified time zone" ; time:long_name = "time since the beginning of the simulation" ; time:standard_name = "time" ; time:calendar = "gregorian" ; time:units = "seconds since 2004-12-31T13:00:00" ; int particle_count(time) ; particle_count:units = "1" ; particle_count:long_name = "number of particles in a given timestep" ; particle_count:ragged_row_count = "particle count at nth timestep" ; double init_mass(data) ; ushort spill_num(data) ; spill_num:long_name = "spill to which the particle belongs" ; spill_num:spills_map = "0: TAMOC plume, " ; double rise_vel(data) ; rise_vel:units = "m s-1" ; rise_vel:long_name = "rise velocity of oil droplet class" ; double longitude(data) ; longitude:units = "degrees_east" ; longitude:long_name = "longitude of the particle" ; longitude:standard_name = "longitude" ; int age(data) ; age:units = "seconds" ; age:long_name = "age of particle from time of release" ; double depth(data) ; depth:units = "meters" ; depth:long_name = "particle depth below sea surface" ; depth:standard_name = "depth" ; depth:axis = "z positive down" ; double mass(data) ; mass:units = "kilograms" ; mass:long_name = "mass of particle" ; double latitude(data) ; latitude:units = "degrees_north" ; latitude:long_name = "latitude of the particle" ; latitude:standard_name = "latitude" ; short status_codes(data) ; status_codes:flag_meanings = "0: not_released, 2: in_water, 3: on_land, 7: off_maps, 10: evaporated, 12: to_be_removed," ; status_codes:long_name = "particle status code" ; status_codes:flag_values = "7 12 0 10 2 3" ; uint id(data) ; id:long_name = "particle ID" ;

// global attributes: :comment = "Particle output from the NOAA PyGnome model" ; :feature_type = "particle_trajectory" ; :conventions = "CF-1.6" ; :source = "PyGnome version 0.6.0" ; :references = "TBD" ; :institution = "NOAA Emergency Response Division" ; :creation_date = "2018-02-21T11:33:27" ; data:

time = 0, 7200, 14400, 21600, 28800, 36000, 43200, 50400, 57600, 64800, 72000, 79200, 86400, 93600, 100800, 108000, 115200, 122400, 129600, 136800, 144000, 151200, 158400, 165600, 172800, 180000, 187200, 194400, 201600, 208800, 216000, 223200, 230400, 237600, 244800, 252000, 259200 ;

particle_count = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;

group: mass_balance { dimensions: time = UNLIMITED ; // (37 currently) variables: double beached(time) ; double off_maps(time) ; data:

beached = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;

off_maps = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; } // group mass_balance }

ChrisBarker-NOAA commented 6 years ago

The problem was with tamoc/ambient.py

So this is an issue with the tamoc code -- you may want to report that in the tamo repo:

https://github.com/socolofs/tamoc

your netcdf indicates that there were no elements created / released during the run.

I'll try to take a look later today.

bhattvihang commented 6 years ago

Thank you Dr Barker

You were right. Somehow particles were not released. I tried it again and now it seems working.

I am still new to gnome and exploring the code and trying to understand how to set gas and oil fraction in the code.

vihang

ChrisBarker-NOAA commented 6 years ago

glad it's working.

Do note that the gas/oil fraction will only make a difference to TAMOC at this point. GNOME can only deal with "dead" oil.

It is on our list to improve that, but we don't have a timeline for that. It sill make a (probably minor) difference in how fast the oil rises to the surface.