Re: [visad] How can I apply logarithmic scaling to Display.Text position?

Hi Chris-

Glad you figured it out. Sorry I didn't have time to look into this and get back to you. Here are some quick thoughts:

Just as with the annotations, you need to have something that will map your raw height values to the logrithmic vertical dimension. One way would be to add a CoordinateSystem to the pointTupleType so you would have the logHeightType in the domain (through the CS) and the mapping would be picked up. You don't want to change retentionTimeType or mzType, so you want to have IdentityCoordinateSystems for those values. So, you could have IdentityCS's for retentionTimeType and mzType and then have a CartesianProductCoordinateSystem of those and the LogCoordinateSystem for the height and attach that to your pointTupleType.

Alternatively, you could create the LogCoordinateSystem for LogHeight and call the toReference method on that, transforming your height values to logHeight and pass those into the GriddedSet:

LogCoordinateSystem logCS = new LogCoordinateSystem(new RealTupleType(logHeightType));
  float[][] logValues =  logCS.toReference({{heightMin, heightMax}});
  lheightMin = logValues[0][0];
  lheightMax = logValues[0][1];
pointTupletype = new RealTupleType(retentionTimeType, mzType, logHeightType);

// Create the box set.
 return GriddedSet.create(
 pointTupleType,
 new float[][]{
 {rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMax,
 rtMin, rtMin, rtMin, rtMin, rtMax, rtMax, rtMax, rtMax,},
 {mzMin, mzMin, mzMin, mzMin, mzMax, mzMax, mzMax, mzMax,
 mzMin, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax},
 {lheightMin, lheightMin, lheightMax, lheightMax, lheightMax,
 lheightMax, lheightMin, lheightMin, lheightMin, lheightMin,
 lheightMax, lheightMax, lheightMax, lheightMax, lheightMin,
 lheightMin}},
 new int[]{2, 8});


(code above not tested at all).

Good luck!

Don



On 11/1/11 3:16 AM, Pudney Chris (ext) GBJH wrote:
G'day,

 > I am struggling to define a FunctionType that will correctly position
the
 > labels when logarithmic scaling is applied.

I managed to solve this using the following code to include a
LogCoordinateSystem in the range of the annotation function:

// Height Types.
final RealType heightType = RealType.getRealType("Height");
final RealType logHeightType = RealType.getRealType("LogHeight",
CommonUnit.promiscuous);
heightTupleType = new RealTupleType(
heightType, new LogCoordinateSystem(new RealTupleType(logHeightType)),
null);
annotationType = TextType.getTextType("Annotation");
annotationTupleType = new TupleType(new MathType[]{heightTupleType,
annotationType});

// Create a function from domain (retention time and m/z) to text
annotation.
annotationFunction = new FunctionType(domainTuple, annotationTupleType);

The full code is in the project svn repository:

http://mzmine.svn.sourceforge.net/viewvc/mzmine/branches/syngenta_normalize_slider/src/net/sf/mzmine/modules/visualization/threed/ThreeDDisplay.java?revision=2566&view=markup


The final piece of the puzzle is applying logarithmic scaling to the
heights of bounding boxes that are used to highlight individual surface
peaks. The box heights match the peak heights and are created using
GriddedSets:

pointTupletype = new RealTupleType(retentionTimeType, mzType, heightType);

// Create the box set.
return GriddedSet.create(
pointTupleType,
new float[][]{
{rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMax,
rtMin, rtMin, rtMin, rtMin, rtMax, rtMax, rtMax, rtMax,},
{mzMin, mzMin, mzMin, mzMin, mzMax, mzMax, mzMax, mzMax,
mzMin, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax},
{heightMin, heightMin, heightMax, heightMax, heightMax,
heightMax, heightMin, heightMin, heightMin, heightMin,
heightMax, heightMax, heightMax, heightMax, heightMin,
heightMin}},
new int[]{2, 8});

The boxes are rendered correctly for linear scaling of the height axis
but not for logarithmic scaling. Presumably to get this working the
GriddedSet (or similar) must reference the LogCoordinateSystem defined
earlier but how?

I'd be grateful for any suggestions.

Code for this class is here:

http://mzmine.svn.sourceforge.net/viewvc/mzmine/branches/syngenta_normalize_slider/src/net/sf/mzmine/modules/visualization/threed/ThreeDPeakCells.java?revision=2566&view=markup


Thanks,
Chris.

This message may contain confidential information. If you are not the
designated recipient, please notify the sender immediately, and delete
the original and any copies. Any use of the message by you is prohibited.

_______________________________________________
visad mailing list
visad@xxxxxxxxxxxxxxxx
For list information, to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/

--
Don Murray
NOAA/ESRL/PSD and CIRES
303-497-3596
http://www.esrl.noaa.gov/psd/people/don.murray/



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: