Hi ATS community,
I am trying to extract some ATS simulated variables as observations say, transpiration and permeability, at hundreds of points (after identifying the horizontal coordinates of the surface) as a csv file. I know this can be extracted from ats_vis_data, but for now I am looking for other options.
Second approach is possibly by defining a region as “point” for a coordinate in the XML and repeating for each of them. But doing this for hundreds of points will overwhelm the xml file as I need the observations for more than two variables eventually.
I wonder if there is a third approach, which is possibly via adding these hundreds of points in the mesh as labeled set in WW. I followed a similar discussion regarding this. I tried to adapt this approach but could not succeed. Here are my steps in WW:
1. First, the lat and lon of points of my interest are stored in df_NHD_points. There are 528 observation points. m2 is my mesh.
2. Appended the observation_points as cell in the mesh.
all_observation_point_list = []
for index, row in df_NHD_points.iterrows():
# Create a shapely Point object from Longitude and Latitude coordinates
point = Point(row['Longitude_RC'], row['Latitude_RC'])
# Append the Point object to the list
all_observation_point_list.append(point)
# generate the corresponding observation cells
my_obs_cell=[]
# Searching for the index
for ic, cell in enumerate(m2.conn):
points = np.array([m2.coords[i] for i in cell])
polygon = shapely.geometry.Polygon(points)
# Check if any point in all_observation_point_list is contained within the polygon
for observation_point in all_observation_point_list:
if polygon.contains(observation_point):
my_obs_cell.append(ic)
3. Added the labeled set and extruded the mesh
# add the observation cells to 2D mesh
new_id = m2.next_available_labeled_setid()
m2.labeled_sets.append(LabeledSet("obs_cells", new_id, "CELL", my_obs_cell,
to_extrude=True))
Doing this, I can see the labeled set and ent_ids allocated for “obs_cell” for both 2D and 3D. “obs_cell” also appears in XML as region: labeled set.
I first tried to get “transpiration” as follows:
<ParameterList name="obs_cell_transpiration" type="ParameterList">
<Parameter name="observation output filename" type="string" value="obs_cell_transpiration.csv" />
<Parameter name="delimiter" type="string" value="," />
<Parameter name="time units" type="string" value="d" />
<Parameter name="times start period stop" type="Array(double)" value="{ 0, 1,-1}" />
<Parameter name="times start period stop units" type="string" value="d" />
<ParameterList name="observed quantities" type="ParameterList">
<ParameterList name="transpiration [m d^-1]" type="ParameterList">
<Parameter name="variable" type="string" value="surface-transpiration" />
<Parameter name="region" type="string" value="obs_cells" />
<Parameter name="location name" type="string" value="cell" />
<Parameter name="functional" type="string" value="point" />
<Parameter name="time integrated" type="bool" value="true" />
</ParameterList>
</ParameterList>
</ParameterList>
The simulation went through, generated “obs_cell_transpiration.csv”. But all values for transpiration were “nan”. Also, although I got all nan values at daily time step, I got only 1 vector/column for transpiration. But I was expecting 528 columns, as I have 528 points defined in obs_cells. In other words, the output matrix was 1 X Time while I am looking for 528 X Time.
My Questions:
1) I might be missing many things here. Can you please help me identify? More importantly, is this (the third) approach reasonable?
2) I assume I need to define a new .csv file to store the output for every new variable of my interest. Is this assumption valid?
2) Can this (third) approach be helpful if I need the outputs at these observation points for their entire column, e.g., porosity?
Any suggestions will be helpful.
Thank you,
Sundar Niroula
Hi all,
Following up on this thread,
While I was able to accurately extract surface observations by defining {x,y} as region point (with Ethan's help, Thanks!), I am getting “nan” when I extract subsurface variables like “water content” and “saturation-liquid’ across depths. The nan values are only seen in the observation (.csv) files. The model runs successfully, and I can see non-nan values for “water content” and “saturation-liquid’ in paraview.
For subsurface observations, I use {x,y,z} as region point. I define z as the centroid elevation of the cell that contains {x,y}, given by z = m2.centroid[xy_containing_cell_index,2]. For layer 0, I simply assign z as the elevation (to see what happens!). For the first layer (layer1), I set elevation (or z1) to be the difference between z (surface) and half the depth of the first layer. (Just to note, my first layer is 0.05m thick). And so on for other layers. The following is an example of my approach for layer 0 and layer 1 at one point location.
Region Definition:
<ParameterList name="obs_pt_150_layer_0" type="ParameterList">Observation Definition:
<ParameterList name="water_content_obs_layer" type="ParameterList">I might be missing something here or making inaccurate assumptions. Has anybody faced and resolved such issue? I know there
was a similar discussion here before but there were no further updates.
I would appreciate any thoughts or suggestions.
Thank you,
Sundar Niroula
So nan means that the region was empty (as it divides by total cell volume for “integral” or “average”), which it sounds like you concluded too.
Your process sounds right for getting z coordinates that should be “in the prism” defined in the 3D mesh. We’ve had some trouble in the past of getting the cell’s “does a cell contain a given point” algorithm correct, so it’s possible you’re doing it right and the code is still not resolving the point to the right cell. But I thought that was fixed. Can you plot the mesh in Paraview or VisIt and confirm that the point you are using for the region is correct (e.g. “inside the mesh and should resolve to _some_ cell”). If you can do that, send me directly a mesh and input file, and I can get someone to take a look to see why the point region isn’t being found in any cell.
Ethan
--
You received this message because you are subscribed to the Google Groups "Amanzi-ATS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ats-users+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-users/f0b8a8c1-2694-4bc7-8dc1-b59940c49346n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ats-users/38ce16ef-4385-4dfb-ac6c-80544f70f499n%40googlegroups.com.