hydroframe / PF_Model_Evaluation

Repo for evaluating parflow simulations and spinup
3 stars 0 forks source link

Problem with np.sum in 00spinup.py #7

Open aktriplett opened 3 years ago

aktriplett commented 3 years ago

When adding up np arrays, using np.sum results in subsurface_storage, surface_storage and et unable to be calculated because they have undefined values outside the mask. This was fixed for me by changing np.sum to np.nansum. This has worked for myself and Jun Zhang.

Ex. below:

total subsurface storage for this time step is the summation of substorage across all x/y/z slices

subsurface_storage[i, ...] = **np.nansum**(
    calculate_subsurface_storage(mask, porosity, pressure, saturation, specific_storage, dx, dy, dz),
    axis=(0, 1, 2)
)
vineetbansal commented 3 years ago

@aktriplett .. I was purposely avoiding a nansum because undefined values of pressure/saturation outside the mask should have no bearing on the subsurface storage calculations, and the code should be tolerant of those values. The results of the calculate_subsurface_storage function should not return any nans. If they are, then you've likely discovered a bug. Let me get in contact with you to get more details on this..