Logarithmic color tables

How do I...?
Post Reply
User avatar
dartcom
Posts: 7
Joined: Mon Oct 08, 2018 9:17 am

Logarithmic color tables

Post by dartcom »

We have some MODIS and VIIRS Chlorophyll-a products in GeoTIFF format generated by the NASA DRL IPOPP software.

We've created a formula to convert the 0-255 values in the GeoTIFF files to mg^m-3 values in the range 0.01 to 100. However the scale is logarithmic rather than linear, so applying the standard Chlorophyll-a color table to the mg^m-3 values specifying the range as 0.01 to 100 doesn't produce the correct results.

Is there any way of altering the scale of color tables in McIDAS-V from linear to logarithmic?

Thanks in advance,
Chris Wright
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: Logarithmic color tables

Post by bobc »

Hello Chris,

It currently isn't possible to make a logarithmic color enhancement in McIDAS-V. Adding this functionality is part of McIDAS-V Inquiry 1153, though I have no estimate on when or if this work will be completed.

I've seen other uses have been able to work around this by displaying the log of the data values. For example, you could create a formula:

Code: Select all

log(data)

When you evaluate the formula in the Field Selector, you would select your GeoTIFF formula.

In my fairly limited testing of this, one thing I ran into is that the natural log of 0 isn't defined. So, if your data includes any zero values, they would be passed through the log() function and the minimum value of your enhancement would be set to 'missing' and nothing would be displayed. If you run into this problem, you can make use of the setToMissing() JPythonMethod to set the 0 data values to missing before running the log(). For example, I set up this function in my Jython Library:

Code: Select all

def logData(data):
    # replace any zero data values with NaN
    missData = setToMissing(data,0)
    # run log function on setToMissing output
    lData = log(missData)
    return lData

When I call this logData function through a formula, the min and max values of the enhancement are actual values and not missing.

Please let me know if you have any questions about this.

Thanks,
Bob Carp
McIDAS Help Desk
User avatar
dartcom
Posts: 7
Joined: Mon Oct 08, 2018 9:17 am

Re: Logarithmic color tables

Post by dartcom »

Hi Bob, thanks for getting back to me.

I wasn't aware of the setToMissing function, so I've added it to all our formula functions so zero values (which are fill data anyway) are set to NaN. This has resolved a problem I had where the fill data was being colored using the minimum value in the color table. It's now transparent, which has the added bonus of allowing multiple products to be overlaid, e.g. SST and LST.

For the read-outs and color bar scale to be correct, unfortunately I can't really pass the data through the log function as you suggested.

The only other solution I can think of is to add a breakpoint at each color change in the color table so the logarithmic scale is approximated to a series of linear scales. I think we might have to go with that for the time being, although it's going to be time-consuming to set up!

Best Regards,
Chris
User avatar
dartcom
Posts: 7
Joined: Mon Oct 08, 2018 9:17 am

Re: Logarithmic color tables

Post by dartcom »

Further to my earlier reply, I ended up using Excel to generate a color table containing 270,977 entries.

I spread out the colors in it to produce a pseudo-logarithmic scale and saved it as a text file, then imported it into McIDAS-V as a color table.

It works perfectly, producing the correct colors.

Chris
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: Logarithmic color tables

Post by bobc »

Thanks for following up, Chris. I'm glad that you were able to get things working!

Please let me know if you have any other questions.

Bob
Post Reply