mcIDAS EU in McIDAS-V

How do I...?
User avatar
ghansham
Posts: 175
Joined: Thu Nov 11, 2010 5:40 pm

mcIDAS EU in McIDAS-V

Post by ghansham »

Hi all

Do we have a java class as part of McV code base that generates color table
following the McIDAS EU interpolation logic given the break points and its corresponding
values. Say this:

EU TABLE WV_BLUE
Brightness Blue Green Red
min max min max min max min max
--- --- --- --- --- --- --- ---
0 109 0 0 0 0 0 0
110 141 0 3 0 251 255 255
142 171 8 166 243 0 247 3
172 191 170 255 12 255 15 255
192 218 246 1 250 107 246 1
219 254 7 248 110 247 1 4
255 255 255 255 255 255 255 255



Regards
Ghansham
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: mcIDAS EU in McIDAS-V

Post by bobc »

Hi Ghansham -

A programmer and I looked into this and you cannot export tables like this in McIDAS-V. The closest you can get is by going to the Color Table Editor and choosing to export the table in the "GEMPAK color table (*.tbl)" format. However, this lists a simple column of RGB values like:

Code: Select all

red    green  blue
8      0      255
7      51     254
5      102    252
4      153    250
2      204    248
8      212    207
15     221    166
22     229    125
29     238    83
36     246    42

This format just lists the RGB value of each color bin (the rectangle boxes) in the enhancement in the Color Table Editor. It doesn't list out interpolated values between breakpoints or anything like that (like McIDAS-X does). In the past, there was a request to add the ability to export McIDAS-X formatted enhancements (*.ET) from McIDAS-V, but this wasn't done due to a variety of differences between enhancements in the two software packages.

If you have any questions about this, please let me know.

Thanks -
Bob Carp
McIDAS Help Desk
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: mcIDAS EU in McIDAS-V

Post by joleenf »

Hi Ghansham,

I have code to write a batch from a McIDAS-V color table. I need to find it and I will send it to you.

Joleen
User avatar
ghansham
Posts: 175
Joined: Thu Nov 11, 2010 5:40 pm

Re: mcIDAS EU in McIDAS-V

Post by ghansham »

Hi all

The 256-entry color table if we generate using the indices provided, is not applied correctly as for calculating those indices,
the function is not same. It has two parts,
1. < 176
2. > 176.
McIDAS-V/IDV apply linear lookup tables.
VisAD has capability to apply such color enhacements using Functions but there is no interface to pass functions from
Idv/mcidasv to visad.

Regards
Ghansham
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: mcIDAS EU in McIDAS-V

Post by joleenf »

Hi Ghansham,

I am sorry, maybe I misunderstood your question. Many of the color tables in McV are linear, to convert them to the bi-linear, I use this function which reads the current table, converts to bilinear, outputs to an ascii file and imports it back into McV.

If you need to export to a McX color table, perhaps read the new file and create a batch?

Code: Select all

def convertColorTable(inputCT=None, outputCT=None, category='User', ctrange=(163,330)):
    """
         Usage:  convertColorTable(inputCT='WVJL2', outputCT='WVJL2_163_330', category='User')
 
        inputCT:  this is a color table which is scaling well for pixel "Brightness
                  Values" (UNIT=BRIT or brightness in field selector) values but not for
                  "Brightness Temperature" Values (UNIT=TEMP or Temperature in field selector)
        outputCT: desired name and path of output color table as ascii file name.
                  (outputfile will be of form filename.ascii)

        category:  Category name for fileing in color table
                 
        ctrange:  (min,max) the Brightness Temperature Range
                for the new Color Table (in Kelvin)
    """

    import ucar.unidata.util.ColorTable as ColorTable
    import os
   
   
    #check if inputCT exists in color table manager
    # load old McX color table
    ctm=_mcv.getColorTableManager()
    ct = ctm.getColorTable(inputCT)
    # don't continue if color table is not in list
    if (ct is None):
        raise NameError ('Color Table Not Found In Color Table Manager: {}'.format(inputCT))
    table = ct.getColorTable()
    oldColorList=ct.getColorList()
   
   
    # check ascii text filename
    filename, file_extension = os.path.splitext(outputCT)
    if (file_extension != '.ascii'):
        outputCT='{}.{}'.format(filename,'ascii')

   
    # check color table manager to see if ct in already in manager
    newctname=os.path.basename(filename)
    ct_checkifnew = ctm.getColorTable(newctname)
       
    # get scale of newCT from temp to BRIT  (assuming bi-linear scaling applied to 163-330 K)
    minTempScale = 163     # this should remain fixed!!!!!
    maxTempScale = 330     # this should remain fixed!!!!!
    scale = float(maxTempScale - minTempScale)/float(255)
   
    with open(outputCT, 'w+') as fh:
        for temp in range(ctrange[0],ctrange[1]+1):
            if (temp < 242):
                BV = 418 - temp
            else:
                BV = 660 - (2*temp)
   
            newInd = int((temp - ctrange[0])/scale)   #!!! Changed on September 20, 2016
            # set rgb of newCT
            thisBlue=oldColorList[BV].getBlue()
            thisRed=oldColorList[BV].getRed()
            thisGreen=oldColorList[BV].getGreen()
            print ('Index: {}, Temperature: {}, Color: {}'.format(newInd, temp, oldColorList[BV]))
   
            rgbLine='{} {} {}\n'.format(thisRed, thisGreen, thisBlue)
            fh.write(rgbLine)
   
    # import new color table
    test=importEnhancement(filename=outputCT, category=category)
User avatar
ghansham
Posts: 175
Joined: Thu Nov 11, 2010 5:40 pm

Re: mcIDAS EU in McIDAS-V

Post by ghansham »

Thanks Joleen. Thats what I was looking for.
Couple of points:
1. Please attach a sample input CT.
2. Is the input CT hacing 256 colors?
3. Does the number of colors get reduced to 167 in the output color table?
Wont this make the output image reduce the variation in image and make it
flat as number of colors is reduced? I may be incorrect. I will try to run your code.
Kindly send one sample input and corresponding output file.

Regards
Ghanshan
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: mcIDAS EU in McIDAS-V

Post by joleenf »

Hi Ghansham,

Here is a sample color table (
GA20P1.ET
(3.19 KiB) Downloaded 357 times
) that we tend to use on water vapor.

Yes, it does reduce the number of colors, it is my understanding, it also replicates the endpoints and the formula within the code in McIDAS-X for IR channels.

For more colors, you might want to try importing two AWIPS color tables which I will have to link by ftp
ftp://ftp.ssec.wisc.edu/pub/incoming/WV_Dry_Yellow.cmap
ftp://ftp.ssec.wisc.edu/pub/incoming/color-11-new.cmap

(GA20P1.ET)
Brightness Blue Green Red
min max min max min max min max
--- --- --- --- --- --- --- ---
0 23 0 0 0 0 0 0
24 63 0 0 0 0 6 255
64 103 0 0 6 255 255 255
104 165 4 255 251 0 251 0
166 191 255 255 10 255 10 255
192 222 247 0 247 0 247 0
223 254 0 0 0 0 0 0
255 255 255 255 255 255 255 255


I hope this helps.

Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: mcIDAS EU in McIDAS-V

Post by joleenf »

Ghansham,

You are also correct that I need to adjust my code to use the full range from 0-255, I should be increasing by 0.5 degrees for each step after 242 K. I am sorry I never noticed that bug. :oops:

Joleen
User avatar
ghansham
Posts: 175
Joined: Thu Nov 11, 2010 5:40 pm

Re: mcIDAS EU in McIDAS-V

Post by ghansham »

Hi Joleen

Exactly what I was also thinking on same lines.
Creating a lut of 336 entries ((330-163)*2).

Please send me updated code whenever you get time.
No hurry..

Thanks a lot.

Regards
Ghansham
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: mcIDAS EU in McIDAS-V

Post by joleenf »

Hi Ghansham,

Would I want ((330-163)*2) = 334 colors (that would exceed the old number of levels)

or

(330-242.5)*2 + (242-163) = 254 colors?

I think it is the second case.

Joleen
Post Reply