NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Don, Don Murray wrote:
Hi- I'm trying to use the GridCoordinateSystem class to support a domain with a time and space varying vertical coordinate. I have a domain: (lon, lat, s_rho) where s_rho is dependent on some other variables. I wanted to create a CoordinateSystem which would transform (lon, lat, s_rho) <-> (Longtitude, Latitude, Altitude). My idea was to create a new domain with at RealTupleType of (lon,lat, s_rho) and a GridCoordinateSystem to tranform to (Longitude, Latitude, Altitude). To create the GridCoordinateSystem, I created a new Gridded3DSet, replacing the s_rho values with the Altitude values at each point: GriddedSet defaultSet = createLonLatSRho(); RealTupleType setType = ((SetType)defaultSet.getType()).getDomain(); float[][] samples = defaultSet.getSamples(); samples[2] = getAltitudeValuesAtEachPoint(); RealType[] types = setType.getRealComponents(); RealTupleType newDomainType new RealTupleType(types[0], types[1], RealType.Altitude) int[] lengths = defaultSet.getLengths(); Unit[] newDomainUnits = newDomainType.getDefaultUnits(); newDomainUnits[2] = CommonUnit.meters; Gridded3DSet newDomain = new Gridded3DSet( newDomainType, samples, lengths[0], lengths[1], lengths[2], null, newDomainUnits, null, false, false); CoordinateSystem gcs = new GridCoordinateSystem(newDomain); RealTupleType newSetType new RealTupleType(setType.getRealComponents(), gcs, null); defaultSet = new Gridded3DSet(newSetType, defaultSet.getSamples(), lengths[0], lengths[1], lengths[2], null, dset.getSetUnits(), oldErrors, false); (not sure if the above compiles, just more of a guide to what I'm trying to do). What I get is an Exception in RealTupleType:visad.UnitException: RealTupleType: CoordinateSystem Units must be convertable with default Unitsat visad.RealTupleType.<init>(RealTupleType.java:183) because in GridCoordinateSystem, the default units are set to null in the constructor and the DefaultUnits of the set are (degree, degree, "").Am I going about this all wrong? Should I use an EmpericalCS
It looks like this is exactly what EmpericalCS was built for. I would consider using an IdentityCoordinateSystem for the (lon, lats), an EmpiricalCoordinateSystem for s_sho -> altitude and finally a CartesianProductCoordinateSystem of the two. I think this would be more efficient. I guess you'd need one of these for each time step. TomR
visad
archives: