[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# [IDV #WFY-428381]: Subtract a 2D field from every level of a 3D field?

• Subject: [IDV #WFY-428381]: Subtract a 2D field from every level of a 3D field?
• Date: Thu, 18 Nov 2021 11:56:45 -0700

```> > Hi Yuan.
> > Not sure if this support ticket went through, I got no response email,
> > sending again for official record.
> > Brian
> >
>
> Yes, I got it.
> I am thinking about adding a Java API to do this task. I will let you know if
> I
> have a solution.
>
> Yuan

Hi Brian,

I have a Jython formula below, the problem is that there are a lot of missing
data in both SatEPT and EPT, so you can
create a plan view display, not the 3d isosurface.

Yuan

def verticalDiff(grid3d, grid2d):
""" Computes a vertical substract of a 2D grid.
"""
from visad import FieldImpl
from visad import FlatField
from visad import Real
def twothreeDiff(grid_sample3d,grid_sample2d):
from visad import FlatField
levels=getLevels(grid_sample3d)
tempFF=FlatField(grid_sample3d.getType(),grid_sample3d.getDomainSet())

dims=range(len(grid_sample3d.getDomainSet().getLengths()))
leveldim=GridUtil.getSpatialDomain(grid_sample3d).getManifoldDimension()
dims.pop(leveldim-1)
latlonlen=1
for i in dims:

latlonlen=latlonlen*len(set(grid_sample3d.getDomainSet().getDoubles()[i]))
vals=grid_sample3d.getValues()[0]

levsF=grid_sample3d.getDomainSet().getDoubles()[2] #must be manifold
dimension
levslice0=GridUtil.make2DGridFromSlice(grid_sample2d)
for level in levels:

levslice=GridUtil.make2DGridFromSlice(GridUtil.sliceAtLevel(grid_sample3d,level))

diff_levslice=sub(levslice,levslice0)
ind=levsF.index(level)
vals[ind:ind+latlonlen]=diff_levslice.getValues()[0]
tempFF.setSamples([vals])
return tempFF
tempFI=grid3d.clone()
for i in range(len(grid3d)):

tempFI.setSample(i,twothreeDiff(grid3d.getSample(i),grid2d.getSample(i)),0)
return tempFI

> >
> > > Is there a way to broadcast a 2D array (or one selected level from a 3D
> > > grid), so that I can subtract it from a 3D grid?
> > >
> > > Here is the error I get in a clean simple test: trying to make T3d - T1000
> > >
> > >
> > > Creating display: Isosurface
> > > visad.SetException: visad.SetException: Gridded3DSet.valueToGrid:
> > > ManifoldDimension must be 3
> > > Gridded3DSet.valueToGrid: ManifoldDimension must be
> > > 3
> > >
> >
> >
>

Ticket Details
===================
Ticket ID: WFY-428381
Department: Support IDV
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web.  If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.

```