Fw: How to set Latitude and Longitude range (Vis5D topography file), make it 0 ~ 360
Curtis Rueden
ctrueden at wisc.edu
Fri May 26 12:29:19 MDT 2006
Hi,
I realize it's been quite awhile since you sent your code. I apologize for
the delay; I've been busier than I thought. But I finally found time to look
into your problem a bit.
I think this is a really nasty problem. The main issue is that as you said,
your ranges do not line up.
The McIDAS map file OUTLSUPW has a range from -180 to 180. Normally, when a
data object has the wrong domain set range, you can just replace the domain
set. But in this case, the McIDAS map file *is* the set, and it's a UnionSet
of a ton of Gridded2DSets. Replacing the range on all of those would be a
major hassle. Maybe another VisAD developer knows an easy way to redefine a
McIDAS map file's sampling range, but I do not.
The netCDF file rh.nc has a range from 0 to 360, which would need to be
readjusted to -180 to 180. Unfortunately, it is a FieldImpl with 1D function
domain composed of a series of FlatFields with Gridded3DSets, meaning that
surgically replacing the domain set by changing the domain values requires
some work. I tried inserting some code into your class before the display
creation to do this:
FieldImpl image_field = (FieldImpl) image_sequence;
int num = ((GriddedSet)
image_field.getDomainSet()).getLengths()[0];
for (int i=0; i<num; i++) {
FlatField ff = (FlatField) image_field.getSample(i);
Gridded3DSet set = (Gridded3DSet) ff.getDomainSet();
float[][] samps = set.getSamples(false);
for (int j=0; j<samps[0].length; j++) samps[0][j] -= 180;
int[] lengths = set.getLengths();
set = new Gridded3DSet(set.getType(), samps, lengths[0],
lengths[1], lengths[2], set.getCoordinateSystem(),
set.getSetUnits(), set.getSetErrors(), false, false);
System.out.println("image_sequence[" + i + "] set = " +
set);//TEMP
ff = new FlatField((FunctionType) ff.getType(), set,
ff.getRangeCoordinateSystem()[0], null, ff.getRangeSets(),
null);// ff.getDomainUnits());
image_field.setSample(i, ff, false);
}
But ran into problems. I am probably making things far more complicated than
they need to be, but cannot think of a simpler way to the solve the problem.
I am not very familiar with VisAD's Lat/Lon support, so maybe it is supposed
to wrap around in a friendlier way?
One question I have is, why do you need the range to be 0 to 360? Just for
cosmetic reasons? If so, you can use the AxisScale features to relabel the
axis to say 0 and 360, but under the hood still have the range be -180 to
180.
Maybe one of the other VisAD developers has a better clue about this
problem. I have taken the code you sent and converted into a standalone
application and placed it online at:
http://skyking.microscopy.wisc.edu/curtis/auto3DVisad
(After grabbing the files, executing "./run" in the target directory
launches the program.)
Sorry I couldn't be more helpful.
-Curtis
P.S. You do not need these lines:
DataReference image_ref = new DataReferenceImpl("NetcdfData");
image_ref.setData(image_sequence);
display.addReference(image_ref);
because you created the display using makeSimpleDisplay, which already takes
care of adding a reference for the image_sequence data object.
On 5/16/06, 劉育帆 <monica at cwb.gov.tw> wrote:
>
> Hello,
>
> I mean that "Netcdf" file data is main, "McIDAS Base Map" file and "Vis5D
> topography" file data is secondary.
> So, "McIDAS Base Map" file and "Vis5D topography" file data domain should
> be ranging from 0 to 360.
>
> My netcdf file range :
> Latitude : -90 ~ 90
> Longitude : 0.0 ~ 357.5
>
> "McIDAS Base Map" file and "Vis5D topography" file range
> Latitude : -90 ~ 90
> Longitude : -180.0 ~ 180.0
>
> I want to be :
>
> My netcdf file range :
> Latitude : -90 ~ 90
> Longitude : 0.0 ~ 357.5
>
> McIDAS Base Map" file and "Vis5D topography" file range
> Latitude : -90 ~ 90
> Longitude : 0.0 ~ 357.5
>
> My question is when I just use code
> lonMap.setRange(lonRange[0], lonRange[1]);
>
> "McIDAS Base Map" file still be normally display, but "Vis5D
> topography" file just display range 0 ~ 180 (180 ~ 360 not display, why?)
> So I need way to solve this problem.
> Thanks you :)
>
>
> Monica
>
> ----- Original Message ----- *From:* Curtis Rueden <ctrueden at wisc.edu>
> *To:* 劉育帆 <monica at cwb.gov.tw>
> *Cc:* visad <visad at unidata.ucar.edu>
> *Sent:* Wednesday, May 17, 2006 3:07 AM
> *Subject:* Re: How to set Latitude and Longitude range (Vis5D topography
> file), make it 0 ~ 360
>
> Hi,
>
> I am not an expert on the netCDF format, but will try to comment as best I
> can.
>
> If you do not call setRange at all, does the auto-scaling sets the range
> as -180 to 180? If so, it would seem your data's range is actually -180 to
> 180 (unless perhaps there is a bug in the netCDF reader?). If you want it to
> display as 0 to 360 instead, you could replace the domain set with one
> ranging from 0 to 360, or use an OffsetUnit to adjust the values. However,
> it looks like you have tried to replace the domain set, which should work,
> assuming the ranges of the two data objects line up properly.
>
> If you cannot figure it out, I would be willing to investigate your
> problem a bit if you can send me your data files and source code
> demonstrating the issue.
>
> -Curtis
>
> On 5/14/06, 劉育帆 <monica at cwb.gov.tw> wrote:
> >
> > Dear All:
> >
> > I use a "McIDAS Base Map" file and a "Vis5D topography" file
> > to match a netcdf file. but it get some error..
> >
> > My netcdf file range :
> > Latitude : -90 ~ 90
> > Longitude : 0.0 ~ 357.5
> >
> > I use
> >
> > [code]
> > Vis5DTopoForm topoAdapter = new Vis5DTopoForm();
> > topoImage = topoAdapter.open(new URL(topoFile));
> >
> > //set Latitude and Longitude range, lonRange[0] = 0.0, lonRange[1]
> > 357.5
> > double lonRange[] = lonMap.getRange();
> > double latRange[] = latMap.getRange();
> > lonMap.setRange(lonRange[0], lonRange[1]);
> > latMap.setRange(latRange[0], latRange[1]);
> >
> > ............
> >
> > //topoAdapter
> > FunctionType imageFunctionType = (FunctionType) topoImage.getType();
> > RealTupleType imageDomainType = imageFunctionType.getDomain();
> > RealTupleType imageRangeType = (RealTupleType)
> > imageFunctionType.getFlatRange();
> > ScalarMap rgbMap = new ScalarMap((RealType)
> > imageRangeType.getComponent(0), Display.RGB);
> > display.addMap(rgbMap);
> >
> > //set Vis5D topography map range
> > LinearLatLonSet origin_set
> > (LinearLatLonSet)((FlatField)topoImage).getDomainSet();
> > int origin_length[]
> > origin_set.getLengths();
> > LinearLatLonSet domain_set = new LinearLatLonSet(imageDomainType,
> > lonRange[0], lonRange[1], origin_length[0], latRange[1], latRange[0],
> > origin_length[1]);
> > FlatField vals_ff = new FlatField(imageFunctionType, domain_set);
> > double[][] flat_samples = ((FlatField)topoImage).getValues();
> > vals_ff.setSamples(flat_samples, false);
> >
> > DataReferenceImpl imageRef = new DataReferenceImpl("ImageRef");
> > imageRef.setData(vals_ff);
> > [/code]
> >
> > I try to several ways but not get right result..
> >
> > 1.Anything not to do
> > http://unicle.netfirms.com/visad/ex0502-1.JPG
> >
> > 2.just set Latitude and Longitude range
> > http://unicle.netfirms.com/visad/ex0502.JPG
> >
> > 3.just set Vis5D topography map range(use LinearLatLonSet)
> > http://unicle.netfirms.com/visad/ex0512-1.JPG
> >
> > 4.both "set Latitude and Longitude range" and "set Vis5D topography map
> > range(use LinearLatLonSet)"
> > http://unicle.netfirms.com/visad/ex0512.JPG
> >
> > I think the default range of "Vis5D topography file" is -180 ~ 180.
> > so when I want set the new range 0 ~ 360, it could be error..
> >
> > Could someone give me a direction ? thanks a lot...
> >
>
>
More information about the visad
mailing list