VLab Issue #2841 - SWPC delivery for 14.2.1

Contains functionality for image calculations such
as differencing and ratios.
Also includes config files for displaying SWPC gridded terrestrial data.
Amending commit to address code-review concerns with some java classes.

Change-Id: I3e6e8dbd5015ef825386c1203c333091c6a24f25

Former-commit-id: bcccb662ed [formerly f841786213] [formerly 90a5cf53d3] [formerly 90a5cf53d3 [formerly e02136a026]] [formerly f0f1a832c7 [formerly 90a5cf53d3 [formerly e02136a026] [formerly f0f1a832c7 [formerly 5823fba56ae3036682814548004afd076174bb06]]]]
Former-commit-id: f0f1a832c7
Former-commit-id: b084c86a7b93985367e046baf1b3239542482172 [formerly 94129f483f09e5269c4bcaed7df0cc11fee8fd8f] [formerly 0c053a145b [formerly 25ad64175c]]
Former-commit-id: 0c053a145b
Former-commit-id: 3d70db144f
This commit is contained in:
Stephen Gilbert 2014-01-22 08:21:17 -05:00
parent fc48645209
commit 536dbbe36d
78 changed files with 4155 additions and 3603 deletions

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -0,0 +1,9 @@
colorMapName=SDO_AIA_193
colorBar=@ColorBars/SolarImage/dfltSolarImageColorBar.xml
wavelength=193
intTime=2.273438
displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=runDiffTime(60)

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="http://www.example.org/productType" xmlns:ns3="group">
<resource>GOES15-SXI-FM3</resource>
<attrSetGroupName>ALL</attrSetGroupName>
<attrSetGroupName>GOES15-SXI-FM3-ALL</attrSetGroupName>
<attrSetNames>PTHNA-0026,PTHNA-04,PTHK-005,PTHK-04,TM-0026,TM-05,TM-26,BE12A-005,BE12A-1</attrSetNames>
</AttributeSetGroup>

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -0,0 +1,9 @@
colorMapName=Gray
colorBar=@ColorBars/SolarImage/dfltSolarImageColorBar.xml
wavelength=6562.808
site=LE
displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=runDiffTime(5)

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>NSO-GONG</resource>
<attrSetGroupName>ALL</attrSetGroupName>
<attrSetNames>BB,CT,LE,ML,TC,TD,UD</attrSetNames>
<attrSetGroupName>NSO-GONG-ALL</attrSetGroupName>
<attrSetNames>BB,CT,LE,ML,TC,TD,UD,LE-func</attrSetNames>
</AttributeSetGroup>

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>SDO-AIA</resource>
<attrSetGroupName>ALL</attrSetGroupName>
<attrSetNames>AIA131,AIA335,AIA211,AIA193,AIA171,AIA1600,AIA1700,AIA4500,AIA94,AIA304,THEMATIC</attrSetNames>
<attrSetGroupName>AIA-ALL</attrSetGroupName>
<attrSetNames>AIA131,AIA335,AIA211,AIA193,AIA193-runDiff,AIA171,AIA1600,AIA1700,AIA4500,AIA94,AIA304,THEMATIC</attrSetNames>
</AttributeSetGroup>

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>STEREO-A-EUVI</resource>
<attrSetGroupName>ALL</attrSetGroupName>
<attrSetGroupName>A-EUVI-ALL</attrSetGroupName>
<attrSetNames>195</attrSetNames>
</AttributeSetGroup>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>STEREO-B-EUVI</resource>
<attrSetGroupName>ALL</attrSetGroupName>
<attrSetGroupName>B-EUVI-ALL</attrSetGroupName>
<attrSetNames>195</attrSetNames>
</AttributeSetGroup>

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -5,3 +5,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -6,3 +6,4 @@ displayUnitStr=DN/sec
alpha=1.0
brightness=1.0
contrast=1.0
imageFunction=

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<inventoryEnabled>true</inventoryEnabled>
<resourceDefnName>ENLIL</resourceDefnName>
<resourceCategory>GRID</resourceCategory>
<resourceParameters>
GDFILE=ENLIL
pluginName=grid
</resourceParameters>
<rscImplementation>ModelFcstGridContours</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>999</dfltFrameCount>
<dfltTimeRange>96</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<inventoryEnabled>true</inventoryEnabled>
<resourceDefnName>EPFLUX</resourceDefnName>
<resourceCategory>GRID</resourceCategory>
<resourceParameters>
GDFILE=EPFlux
pluginName=grid
</resourceParameters>
<rscImplementation>ModelFcstGridContours</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>999</dfltFrameCount>
<dfltTimeRange>96</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<inventoryEnabled>true</inventoryEnabled>
<resourceDefnName>IONTEMP</resourceDefnName>
<resourceCategory>GRID</resourceCategory>
<resourceParameters>
GDFILE=IonTemperature
pluginName=grid
</resourceParameters>
<rscImplementation>ModelFcstGridContours</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>999</dfltFrameCount>
<dfltTimeRange>96</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<inventoryEnabled>true</inventoryEnabled>
<resourceDefnName>SOLARFLUX</resourceDefnName>
<resourceCategory>GRID</resourceCategory>
<resourceParameters>
GDFILE=SolarFlux
pluginName=grid
</resourceParameters>
<rscImplementation>ModelFcstGridContours</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>999</dfltFrameCount>
<dfltTimeRange>96</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<inventoryEnabled>true</inventoryEnabled>
<resourceDefnName>SXI</resourceDefnName>
<resourceCategory>GRID</resourceCategory>
<resourceParameters>
GDFILE=SXI
pluginName=grid
</resourceParameters>
<rscImplementation>ModelFcstGridContours</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator></rscTypeGenerator>
<timeMatchMethod>CLOSEST_BEFORE_OR_AFTER</timeMatchMethod>
<frameSpan>60</frameSpan>
<timelineGenMethod>USE_CYCLE_TIME_FCST_HOURS</timelineGenMethod>
<dfltFrameCount>999</dfltFrameCount>
<dfltTimeRange>96</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -30,6 +30,7 @@
<alpha>${alpha}</alpha>
<brightness>${brightness}</brightness>
<contrast>${contrast}</contrast>
<imageFunction>${imageFunction}</imageFunction>
<metadataMap>
<mapping key="pluginName">
@ -53,6 +54,9 @@
<mapping key="reportType">
<constraint constraintValue="${reportType}" constraintType="EQUALS"/>
</mapping>
<!-- <mapping key="imageFunction">
<constraint constraintValue="${imageFunction}" constraintType="EQUALS"/>
</mapping> -->
</metadataMap>
</resourceData>
</resource>

View file

@ -21,7 +21,191 @@
<styleRuleset>
<!-- GOES SXI Rules -->
<!-- GOES SXI has two set of rules. One is LINEAR and another is LOG.
For same instrument, wavelength and intTime, the first rule on the xml is used.
Users can comment out the first rule if they want to use the second rule. -->
<!-- <styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>BE12A</wavelength>
<intTime>1.0</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>4096</maxValue>
</range>
<defaultColormap>SolarImage/Blue</defaultColormap>
<colorbarLabeling>
<values>1024 2048 3072</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>BE12A</wavelength>
<intTime>0.05</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>81920</maxValue>
</range>
<defaultColormap>SolarImage/Blue</defaultColormap>
<colorbarLabeling>
<values>20480 40960 61440</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>PTHK</wavelength>
<intTime>0.4</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>10240</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<colorbarLabeling>
<values>2560 5120 7680</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>PTHK</wavelength>
<intTime>0.05</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>81920</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<colorbarLabeling>
<values>20480 40960 61440</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>PTHNA</wavelength>
<intTime>0.4</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>10240</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<colorbarLabeling>
<values>2560 5120 7680</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>PTHNA</wavelength>
<intTime>0.026</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>157540</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<colorbarLabeling>
<values>39385 78770 118155</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM1</instrument>
<wavelength>PTHNA</wavelength>
<intTime>0.026</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>157540</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<colorbarLabeling>
<values>39385 78770 118155</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>TM</wavelength>
<intTime>2.6</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>1575</maxValue>
</range>
<defaultColormap>SolarImage/Yellow</defaultColormap>
<colorbarLabeling>
<values>394 788 1182</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>TM</wavelength>
<intTime>0.5</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>8192</maxValue>
</range>
<defaultColormap>SolarImage/Yellow</defaultColormap>
<colorbarLabeling>
<values>2048 4096 6144</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>TM</wavelength>
<intTime>0.026</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>157540</maxValue>
</range>
<defaultColormap>SolarImage/Yellow</defaultColormap>
<colorbarLabeling>
<values>39385 78770 118155</values>
</colorbarLabeling>
</imageStyle>
</styleRule> -->
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<wavelength>BE12A</wavelength>
@ -30,16 +214,42 @@
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LOG">
<minValue>0.</minValue>
<minValue>0</minValue>
<maxValue>3.6122</maxValue>
</range>
<defaultColormap>SolarImage/Blue</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='0.9' label='1024' />
<entry pixelValue="128" displayValue='1.8' label='2048' />
<entry pixelValue="192" displayValue='2.71' label='3072' />
<entry pixelValue="250" displayValue='3.61236' label='4096' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="43" displayValue='0.60206' label='4' />
<entry pixelValue="85" displayValue='1.20412' label='16' />
<entry pixelValue="128" displayValue='1.80618' label='64' />
<entry pixelValue="171" displayValue='2.40824' label='256' />
<entry pixelValue="213" displayValue='3.0103' label='1024' />
<entry pixelValue="255" displayValue='3.61236' label='4096' />
</dataMapping>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM1</instrument>
<wavelength>BE12A</wavelength>
<intTime>1.0</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LOG">
<minValue>0</minValue>
<maxValue>3.6122</maxValue>
</range>
<defaultColormap>SolarImage/Blue</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="43" displayValue='0.60206' label='4' />
<entry pixelValue="85" displayValue='1.20412' label='16' />
<entry pixelValue="128" displayValue='1.80618' label='64' />
<entry pixelValue="171" displayValue='2.40824' label='256' />
<entry pixelValue="213" displayValue='3.0103' label='1024' />
<entry pixelValue="255" displayValue='3.61236' label='4096' />
</dataMapping>
</imageStyle>
</styleRule>
@ -57,11 +267,25 @@
</range>
<defaultColormap>SolarImage/Blue</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.228' label='20480' />
<entry pixelValue="128" displayValue='2.4567' label='40960' />
<entry pixelValue="192" displayValue='3.685' label='61440' />
<entry pixelValue="250" displayValue='4.91339' label='81920' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="28" displayValue='0.60206' label='4' />
<entry pixelValue="57" displayValue='1.20412' label='16' />
<entry pixelValue="85" displayValue='1.80618' label='64' />
<entry pixelValue="114" displayValue='2.40824' label='256' />
<entry pixelValue="142" displayValue='3.01030' label='1024' />
<entry pixelValue="171" displayValue='3.61236' label='4096' />
<entry pixelValue="199" displayValue='4.21442' label='16384' />
<entry pixelValue="228" displayValue='4.81648' label='65536' />
<entry pixelValue="255" displayValue='5.41854' label='262144' />
<!-- <entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="36" displayValue='0.69898' label='5' />
<entry pixelValue="68" displayValue='1.30103' label='20' />
<entry pixelValue="99" displayValue='1.90309' label='80' />
<entry pixelValue="131" displayValue='2.50515' label='320' />
<entry pixelValue="162" displayValue='3.10721' label='1280' />
<entry pixelValue="193" displayValue='3.70927' label='5120' />
<entry pixelValue="224" displayValue='4.31133' label='20480' />
<entry pixelValue="255" displayValue='4.91339' label='81920' /> -->
</dataMapping>
</imageStyle>
</styleRule>
@ -79,11 +303,14 @@
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.00' label='2560' />
<entry pixelValue="128" displayValue='2.005' label='5120' />
<entry pixelValue="192" displayValue='3.01' label='7680' />
<entry pixelValue="250" displayValue='4.0103' label='10240' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="37" displayValue='0.60206' label='4' />
<entry pixelValue="73" displayValue='1.20412' label='16' />
<entry pixelValue="109" displayValue='1.80618' label='64' />
<entry pixelValue="146" displayValue='2.40824' label='256' />
<entry pixelValue="182" displayValue='3.01030' label='1024' />
<entry pixelValue="219" displayValue='3.61236' label='4096' />
<entry pixelValue="255" displayValue='4.21442' label='16384' />
</dataMapping>
</imageStyle>
</styleRule>
@ -102,16 +329,21 @@
<defaultColormap>SolarImage/Green</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.228' label='20480' />
<entry pixelValue="128" displayValue='2.4567' label='40960' />
<entry pixelValue="192" displayValue='3.685' label='61440' />
<entry pixelValue="250" displayValue='4.91339' label='81920' />
<entry pixelValue="28" displayValue='0.60206' label='4' />
<entry pixelValue="57" displayValue='1.20412' label='16' />
<entry pixelValue="85" displayValue='1.80618' label='64' />
<entry pixelValue="114" displayValue='2.40824' label='256' />
<entry pixelValue="142" displayValue='3.01030' label='1024' />
<entry pixelValue="171" displayValue='3.61236' label='428096' />
<entry pixelValue="199" displayValue='4.21442' label='16384' />
<entry pixelValue="228" displayValue='4.81648' label='65536' />
<entry pixelValue="255" displayValue='5.41854' label='262144' />
</dataMapping>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM3</instrument>
<!-- <instrument>SXI-FM3</instrument>-->
<wavelength>PTHNA</wavelength>
<intTime>0.4</intTime>
</solarImageMatches>
@ -123,11 +355,14 @@
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.00' label='2560' />
<entry pixelValue="128" displayValue='2.005' label='5120' />
<entry pixelValue="192" displayValue='3.01' label='7680' />
<entry pixelValue="250" displayValue='4.0103' label='10240' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="37" displayValue='0.60206' label='4' />
<entry pixelValue="73" displayValue='1.20412' label='16' />
<entry pixelValue="109" displayValue='1.80618' label='64' />
<entry pixelValue="146" displayValue='2.40824' label='256' />
<entry pixelValue="182" displayValue='3.01030' label='1024' />
<entry pixelValue="219" displayValue='3.61236' label='4096' />
<entry pixelValue="255" displayValue='4.21442' label='16384' />
</dataMapping>
</imageStyle>
</styleRule>
@ -146,10 +381,43 @@
<defaultColormap>SolarImage/Green</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.3' label='39385' />
<entry pixelValue="128" displayValue='2.6' label='78769' />
<entry pixelValue="192" displayValue='3.898' label='118154' />
<entry pixelValue="250" displayValue='5.19739' label='157538' />
<entry pixelValue="28" displayValue='0.60206' label='4' />
<entry pixelValue="57" displayValue='1.20412' label='16' />
<entry pixelValue="85" displayValue='1.80618' label='64' />
<entry pixelValue="114" displayValue='2.40824' label='256' />
<entry pixelValue="142" displayValue='3.01030' label='1024' />
<entry pixelValue="171" displayValue='3.61236' label='4096' />
<entry pixelValue="199" displayValue='4.21442' label='16384' />
<entry pixelValue="228" displayValue='4.81648' label='65536' />
<entry pixelValue="255" displayValue='5.41854' label='262144' />
</dataMapping>
</imageStyle>
</styleRule>
<styleRule>
<solarImageMatches>
<instrument>SXI-FM1</instrument>
<wavelength>PTHNA</wavelength>
<intTime>0.026</intTime>
</solarImageMatches>
<imageStyle>
<displayUnits label="DN/sec"/>
<range scale="LOG">
<minValue>0.</minValue>
<maxValue>5.1973</maxValue>
</range>
<defaultColormap>SolarImage/Green</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="28" displayValue='0.60206' label='4' />
<entry pixelValue="57" displayValue='1.20412' label='16' />
<entry pixelValue="85" displayValue='1.80618' label='64' />
<entry pixelValue="114" displayValue='2.40824' label='256' />
<entry pixelValue="142" displayValue='3.01030' label='1024' />
<entry pixelValue="171" displayValue='3.61236' label='4096' />
<entry pixelValue="199" displayValue='4.21442' label='16384' />
<entry pixelValue="228" displayValue='4.81648' label='65536' />
<entry pixelValue="255" displayValue='5.41854' label='262144' />
<!-- <entry pixelValue="250" displayValue='5.19739' label='157538' /> -->
</dataMapping>
</imageStyle>
</styleRule>
@ -167,11 +435,13 @@
</range>
<defaultColormap>SolarImage/Yellow</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='0.8' label='394' />
<entry pixelValue="128" displayValue='1.6' label='787' />
<entry pixelValue="192" displayValue='2.398' label='1182' />
<entry pixelValue="250" displayValue='3.19739' label='1575' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="43" displayValue='0.60206' label='4' />
<entry pixelValue="85" displayValue='1.20412' label='16' />
<entry pixelValue="128" displayValue='1.80618' label='64' />
<entry pixelValue="171" displayValue='2.40824' label='256' />
<entry pixelValue="213" displayValue='3.01030' label='1024' />
<entry pixelValue="255" displayValue='3.61236' label='4096' />
</dataMapping>
</imageStyle>
</styleRule>
@ -189,11 +459,14 @@
</range>
<defaultColormap>SolarImage/Yellow</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='0.978' label='2048' />
<entry pixelValue="128" displayValue='1.9567' label='4096' />
<entry pixelValue="192" displayValue='2.935' label='6144' />
<entry pixelValue="250" displayValue='3.91339' label='8192' />
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="37" displayValue='0.60206' label='4' />
<entry pixelValue="73" displayValue='1.20412' label='16' />
<entry pixelValue="109" displayValue='1.80618' label='64' />
<entry pixelValue="146" displayValue='2.40824' label='256' />
<entry pixelValue="182" displayValue='3.01030' label='1024' />
<entry pixelValue="219" displayValue='3.61236' label='4096' />
<entry pixelValue="255" displayValue='4.21442' label='16384' />
</dataMapping>
</imageStyle>
</styleRule>
@ -212,13 +485,18 @@
<defaultColormap>SolarImage/Yellow</defaultColormap>
<dataMapping>
<entry pixelValue="1" displayValue='0' label='1' />
<entry pixelValue="64" displayValue='1.3' label='39385' />
<entry pixelValue="128" displayValue='2.6' label='78769' />
<entry pixelValue="192" displayValue='3.898' label='118154' />
<entry pixelValue="250" displayValue='5.19739' label='157538' />
<entry pixelValue="28" displayValue='0.60206' label='4' />
<entry pixelValue="57" displayValue='1.20412' label='16' />
<entry pixelValue="85" displayValue='1.80618' label='64' />
<entry pixelValue="114" displayValue='2.40824' label='256' />
<entry pixelValue="142" displayValue='3.01030' label='1024' />
<entry pixelValue="171" displayValue='3.61236' label='4096' />
<entry pixelValue="199" displayValue='4.21442' label='16384' />
<entry pixelValue="228" displayValue='4.81648' label='65536' />
<entry pixelValue="255" displayValue='5.41854' label='262144' />
</dataMapping>
</imageStyle>
</styleRule>
</styleRule>
<styleRule>
<solarImageMatches>

View file

@ -56,7 +56,13 @@
defaultValue="1.0"
ncResourceName="SolarImage">
</nc-resourceParameter>
<nc-resourceParameter
paramClass="String"
paramName="imageFunction"
paramType="EDITABLE_ATTRIBUTE"
defaultValue=""
ncResourceName="SolarImage">
</nc-resourceParameter>
<nc-resourceParameter
paramName="satellite"
ncResourceName="SolarImage"

View file

@ -1,94 +0,0 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import java.nio.FloatBuffer;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Callback Linear for Cylindrical Display
*
* <pre>
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/01/2013 958 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class CylindCedDataCallback implements IColorMapDataRetrievalCallback {
protected SolarImageRecord record;
private final ImageData imgData;
/**
* @param record
* @throws VizException
*/
public CylindCedDataCallback(SolarImageRecord record, ImageData imgData)
throws VizException {
this.record = record;
this.imgData = imgData;
}
@Override
public ColorMapData getColorMapData() throws VizException {
// System.out.println("Retrieving solarimage data from HDF5...");
int[] dimensions = new int[] { 360, 180 }; // imgData.getNx(),
// imgData.getNy() };//new
// dimensions
FloatBuffer buffer = FloatBuffer.wrap(imgData.getImageValues());// new
// imageData
return new ColorMapData(buffer, dimensions, ColorMapDataType.FLOAT);
}
public ImageData getImageData() {
return imgData;
}
public double getOriginalValue(double val) {
return val;
}
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime
// * result
// + ((record.getDataURI() == null) ? 0 : record.getDataURI()
// .hashCode());
// result = prime * result + this.getClass().getCanonicalName().hashCode();
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// CylindCarrDataCallback other = (CylindCarrDataCallback) obj;
// if (record.getDataURI() == null) {
// if (other.record.getDataURI() != null)
// return false;
// } else if (!record.getDataURI().equals(other.record.getDataURI()))
// return false;
// return true;
// }
}

View file

@ -1,65 +0,0 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import java.nio.FloatBuffer;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Callback for Cylindrical Display
*
* <pre>
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/01/2013 958 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class LogCylindCedDataCallback extends CylindCedDataCallback {
/**
* @param record
* @throws VizException
*/
public LogCylindCedDataCallback(SolarImageRecord record, ImageData imgData)
throws VizException {
super(record, imgData);
}
@Override
public ColorMapData getColorMapData() throws VizException {
// int[] dimensions = new int[] { getImageData().getNx(),
// getImageData().getNy()};
int[] dimensions = new int[] { 360, 180 };
float[] vals = getImageData().getImageValues();
float[] logVals = new float[vals.length];
for (int n = 0; n < vals.length; n++) {
if (vals[n] <= 0) {
logVals[n] = Float.NEGATIVE_INFINITY;
} else {
logVals[n] = (float) (Math.log10(vals[n]));
}
}
FloatBuffer buffer = FloatBuffer.wrap(logVals);
return new ColorMapData(buffer, dimensions, ColorMapDataType.FLOAT);
}
@Override
public double getOriginalValue(double val) {
return Math.pow(10.0, val);
}
}

View file

@ -1,6 +1,7 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import java.nio.FloatBuffer;
@ -8,21 +9,45 @@ import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType;
import com.raytheon.uf.viz.core.exception.VizException;
/**
*
* dataCallback for SolarImage when LOG scale
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 01/22/2013 958 qzhou Initial Creation.
* </pre>
*
* @author qzhou
* @version 1
*/
public class LogSolarImageDataCallback extends SolarImageDataCallback {
/**
* @param record
* @throws VizException
* @param dataURI
* @throws VizException
*/
public LogSolarImageDataCallback(SolarImageRecord record) throws VizException {
public LogSolarImageDataCallback(SolarImageRecord record)
throws VizException {
super(record);
}
@Override
public ColorMapData getColorMapData() throws VizException {
int[] dimensions = new int[] { getImageData().getNx(), getImageData().getNy() };
if (imgData == null) {
imgData = new ImageData(getImageNx(), getImageNy(), getHeaderData()
.getBitpix(), getHeaderData().getBscale(), getHeaderData()
.getBzero(), getDataFromHDF5().getKernel());
setImageNx(imgData.getNx());
setImageNy(imgData.getNy());
}
int[] dimensions = new int[] { getImageData().getNx(),
getImageData().getNy() };
float[] vals = getImageData().getImageValues();
float[] logVals = new float[vals.length];

View file

@ -1,87 +1,166 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.HeaderData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.SolarImageUtil;
import java.io.File;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import nom.tam.fits.BasicHDU;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.exception.VizException;
/**
*
* dataCallback for SolarImage when LINEAR scale
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 01/22/2013 958 qzhou Initial Creation.
* </pre>
*
* @author qzhou
* @version 1
*/
public class SolarImageDataCallback implements IColorMapDataRetrievalCallback {
protected SolarImageRecord record;
private ImageData imgData;
private final HeaderData headerData;
protected ImageData imgData;
private int imageNx = 0;
private int imageNy = 0;
private int cylindrical = 0;
private int imgDiff = 0;
/**
* @param record
* @throws VizException
* @param dataURI
* @throws VizException
*/
public SolarImageDataCallback(SolarImageRecord record) throws VizException {
this.record = record;
this.imgData = new ImageData(record);
BasicHDU recordHDU = getDataFromHDF5();
this.headerData = new HeaderData(recordHDU);
this.imageNx = headerData.getNx();
this.imageNy = headerData.getNy();
this.imgData = new ImageData(imageNx, imageNy, headerData.getBitpix(),
headerData.getBscale(), headerData.getBzero(),
recordHDU.getKernel());
}
@Override
public ColorMapData getColorMapData() throws VizException {
//System.out.println("Retrieving solarimage data from HDF5...");
if (imgData == null) {
this.imgData = new ImageData(imageNx, imageNy,
headerData.getBitpix(), headerData.getBscale(),
headerData.getBzero(), getDataFromHDF5().getKernel());
this.imageNx = imgData.getNx();
this.imageNy = imgData.getNy();
}
int[] dimensions = new int[] { imgData.getNx(), imgData.getNy() };
FloatBuffer buffer = FloatBuffer.wrap(imgData.getImageValues());
return new ColorMapData(buffer, dimensions, ColorMapDataType.FLOAT);
}
protected float[] getRawData() {
float[] values = null;
byte[] rawData = null;
File loc = HDF5Util.findHDF5Location(record);
IDataStore dataStore = DataStoreFactory.getDataStore(loc);
try {
IDataRecord[] dataRecs = dataStore.retrieve(record.getDataURI());
for (IDataRecord rec : dataRecs) {
if (rec.getName().equals(SolarImageRecord.RAW_DATA)
&& rec instanceof ByteDataRecord) {
rawData = (((ByteDataRecord) rec).getByteData());
}
}
} catch (Exception se) {
se.printStackTrace();
}
return values;
public BasicHDU getDataFromHDF5() throws VizException {
BasicHDU recordHDU = SolarImageUtil.getImageHDU(record);
record.setRawData(null);
return recordHDU;
}
public double getOriginalValue(double val) {
return val;
}
public ImageData getImageData() {
return imgData;
}
public void setImageData(ImageData imgData) {
this.imgData = imgData;
if (imgData != null) {
this.imageNx = imgData.getNx();
this.imageNy = imgData.getNy();
}
}
public SolarImageRecord getRecord() {
return record;
}
public int getImageNx() {
return imageNx;
}
public void setImageNx(int imageNx) {
this.imageNx = imageNx;
}
public int getImageNy() {
return imageNy;
}
public void setImageNy(int imageNy) {
this.imageNy = imageNy;
}
public HeaderData getHeaderData() {
return headerData;
}
public int getCylindrical() {
return cylindrical;
}
public void setCylindrical(int cylindrical) {
this.cylindrical = cylindrical;
}
public int getImgDiff() {
return imgDiff;
}
public void setImgDiff(int imgDiff) {
this.imgDiff = imgDiff;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime
* result
+ ((record.getDataURI() == null) ? 0 : record.getDataURI()
.hashCode());
result = prime * result + this.getClass().getCanonicalName().hashCode();
result = prime * result + cylindrical
+ this.getClass().getCanonicalName().hashCode();
result = prime * result + imgDiff
+ this.getClass().getCanonicalName().hashCode();
result = prime * result
+ ((this.imgData == null) ? 0 : this.imgData.hashCode());
result = prime * result
+ ((this.record == null) ? 0 : this.record.hashCode());
return result;
}
@ -94,11 +173,26 @@ public class SolarImageDataCallback implements IColorMapDataRetrievalCallback {
if (getClass() != obj.getClass())
return false;
SolarImageDataCallback other = (SolarImageDataCallback) obj;
if (record.getDataURI() == null) {
if (other.record.getDataURI() != null)
return false;
} else if (!record.getDataURI().equals(other.record.getDataURI()))
if (this.getHeaderData() != other.getHeaderData()) {
return false;
}
if (this.record == null) {
if (other.getRecord() != null)
return false;
} else if (!this.record.equals(other.getRecord()))
return false;
if (this.getImageData() == null) {
if (other.getImageData() != null)
return false;
} else if (this.getImageData() != other.getImageData()) {
return false;
}
if (this.getCylindrical() != other.getCylindrical()) {
return false;
}
if (this.getImgDiff() != other.getImgDiff()) {
return false;
}
return true;
}

View file

@ -1,5 +1,7 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.actions;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
@ -7,8 +9,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
@ -23,19 +23,18 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 21, 2013 958 qzhou Initial Creation.
*
* 12/17/2013 958 qzhou Fixed cylind and latlon context menu leftover problem
* 01/22/2014 1046 qzhou Move enum to MenuConstants
* </pre>
*
* @author qzhou
* @version 1
*/
public class CarrLatLonAction extends AbstractRightClickAction
implements IMenuCreator {
private Menu menu;
private static String[] latLonIntervals = {"No Overlay", "10", "15", "30", "45", "60"};
public class CarrLatLonAction extends AbstractRightClickAction implements
IMenuCreator {
private Menu menu;
/**
* Default constructor.
@ -48,11 +47,10 @@ public class CarrLatLonAction extends AbstractRightClickAction
@Override
public IMenuCreator getMenuCreator() {
this.setChecked(false);
this.setChecked(false);
return this;
}
@Override
public void dispose() {
if (menu != null) {
@ -68,7 +66,7 @@ public class CarrLatLonAction extends AbstractRightClickAction
}
menu = new Menu(parent);
fillMenu(menu, parent.getDisplay());
return menu;
}
@ -79,50 +77,55 @@ public class CarrLatLonAction extends AbstractRightClickAction
}
menu = new Menu(parent);
fillMenu(menu, parent.getDisplay());
return menu;
}
public void fillMenu(Menu menu, Display d) {
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentInterval = getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).getInterval();
for (String intvl : latLonIntervals) {
boolean selected = intvl.equals(currentInterval);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, intvl, d, selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, currentInterval, d, true));
actionItem.fill(menu, -1);
}
}
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentInterval = getTopMostSelectedResource()
.getCapability(CarrLatLonCapability.class).getInterval();
for (String intvl : MenuConstants.latLonIntervals) {
boolean selected = intvl.equals(currentInterval);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, intvl, d,
selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc,
currentInterval, d, true));
actionItem.fill(menu, -1);
}
}
}
private class ChangeLatLonIntervalInternalAction extends Action {
private String interval;
AbstractVizResource<?, ?> resource = null;
public ChangeLatLonIntervalInternalAction(AbstractVizResource<?, ?> resource, String intvl, Display d, boolean selected) {
public ChangeLatLonIntervalInternalAction(
AbstractVizResource<?, ?> resource, String intvl, Display d,
boolean selected) {
super(intvl);
this.resource = resource;
this.interval = intvl;
this.setChecked(false);
this.interval = intvl;
this.setChecked(false);
if (selected) {
this.setChecked(true);
}
this.setChecked(true);
}
}
/*
@ -142,24 +145,40 @@ public class CarrLatLonAction extends AbstractRightClickAction
*/
@Override
public void run() {
if (interval != null) {
if (this.getText().equals("No Overlay")) {
((SolarImageResource) resource).setLatLonOverlay(false);
((SolarImageResource) resource).isCarrington = false;
}
else {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = true;
}
getTopMostSelectedResource().getCapability(CarrLatLonCapability.class).setInterval(interval);
getTopMostSelectedResource().getCapability(StonyLatLonCapability.class).setInterval("No Overlay");
}
if (interval != null) {
if (this.getText().equals(MenuConstants.latLonIntervals[0])) {
if (getTopMostSelectedResource()
.getCapability(StonyLatLonCapability.class)
.getInterval()
.equals(MenuConstants.latLonIntervals[0])) {
((SolarImageResource) resource).setLatLonOverlay(false);
((SolarImageResource) resource).isCarrington = false;
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).setInterval(
interval);
}
} else {
if (!getTopMostSelectedResource()
.getCapability(CylindricalCedCapability.class)
.getCylind().equals(MenuConstants.projections[1])) {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = true;
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).setInterval(
interval);
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).setInterval(
MenuConstants.latLonIntervals[0]);
}
}
}
getContainer().refresh();
}
}
}
/*
* (non-Javadoc)
@ -172,4 +191,3 @@ public class CarrLatLonAction extends AbstractRightClickAction
}
}

View file

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
/**
* TODO Add Description
* implementation for describing persistable capabilities
*
* <pre>
*
@ -42,7 +42,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
@XmlAccessorType(XmlAccessType.NONE)
public class CarrLatLonCapability extends AbstractCapability {
private String interval = "No Overlay";
private String interval = MenuConstants.latLonIntervals[0];
/**
* @return the outlineWidth
@ -62,7 +62,6 @@ public class CarrLatLonCapability extends AbstractCapability {
}
}
@Override
public AbstractCapability clone() {
CarrLatLonCapability oc = new CarrLatLonCapability();

View file

@ -1,5 +1,7 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.actions;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
@ -7,8 +9,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
@ -23,6 +23,8 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/02/2013 958 qzhou Initial Creation.
* 12/17/2013 958 qzhou Fixed cylind and latlon context menu leftover problem
* 01/22/2014 1046 qzhou Move enum to MenuConstants
*
* </pre>
*
@ -30,12 +32,10 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* @version 1
*/
public class CylindricalCedAction extends AbstractRightClickAction
implements IMenuCreator {
private Menu menu;
private static String[] projections = {"No Projection", "Stonyhurst", "Carrington"};
public class CylindricalCedAction extends AbstractRightClickAction implements
IMenuCreator {
private Menu menu;
/**
* Default constructor.
@ -48,11 +48,10 @@ public class CylindricalCedAction extends AbstractRightClickAction
@Override
public IMenuCreator getMenuCreator() {
this.setChecked(false);
this.setChecked(false);
return this;
}
@Override
public void dispose() {
if (menu != null) {
@ -68,7 +67,7 @@ public class CylindricalCedAction extends AbstractRightClickAction
}
menu = new Menu(parent);
fillMenu(menu, parent.getDisplay());
return menu;
}
@ -79,51 +78,54 @@ public class CylindricalCedAction extends AbstractRightClickAction
}
menu = new Menu(parent);
fillMenu(menu, parent.getDisplay());
return menu;
}
public void fillMenu(Menu menu, Display d) {
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentCylind = getTopMostSelectedResource().getCapability(
CylindricalCedCapability.class).getCylind();
for (String proj : projections) {
boolean selected = proj.equals(currentCylind);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeCylindricalCedAction(rsc, proj, d, selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeCylindricalCedAction(rsc, currentCylind, d, true));
actionItem.fill(menu, -1);
}
}
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentCylind = getTopMostSelectedResource().getCapability(
CylindricalCedCapability.class).getCylind();
for (String proj : MenuConstants.projections) {
boolean selected = proj.equals(currentCylind);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeCylindricalCedAction(rsc, proj, d, selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeCylindricalCedAction(rsc, currentCylind, d,
true));
actionItem.fill(menu, -1);
}
}
}
private class ChangeCylindricalCedAction extends Action {
private String cylind;
AbstractVizResource<?, ?> resource = null;
public ChangeCylindricalCedAction(AbstractVizResource<?, ?> resource, String cylind, Display d, boolean selected) {
public ChangeCylindricalCedAction(AbstractVizResource<?, ?> resource,
String cylind, Display d, boolean selected) {
super(cylind);
this.resource = resource;
this.cylind = cylind;
this.setChecked(false);
this.cylind = cylind;
this.setChecked(false);
if (selected) {
this.setChecked(true);
}
this.setChecked(true);
}
}
/*
@ -143,26 +145,63 @@ public class CylindricalCedAction extends AbstractRightClickAction
*/
@Override
public void run() {
if (cylind != null) {
if (this.getText().equals("No Projection")) {
((SolarImageResource) resource).setCylindrical(0);
//((SolarImageResource) resource).cylindrical = 0;
}
else if (this.getText().equals("Stonyhurst")) {
((SolarImageResource) resource).setCylindrical(1);
}
else if (this.getText().equals("Carrington")) {
((SolarImageResource) resource).setCylindrical(2);
}
getTopMostSelectedResource().getCapability(CylindricalCedCapability.class).setCylindrical(cylind);
}
if (cylind != null) {
if (this.getText().equals(MenuConstants.projections[0])) {
((SolarImageResource) resource).setCylindrical(0);
} else if (this.getText().equals(MenuConstants.projections[1])) {
((SolarImageResource) resource).setCylindrical(1);
if (!getTopMostSelectedResource()
.getCapability(CarrLatLonCapability.class)
.getInterval()
.equals(MenuConstants.latLonIntervals[0])) {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = false;
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).setInterval(
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class)
.getInterval());
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).setInterval(
MenuConstants.latLonIntervals[0]);
}
} else if (this.getText().equals(MenuConstants.projections[2])) {
((SolarImageResource) resource).setCylindrical(2);
if (!getTopMostSelectedResource()
.getCapability(StonyLatLonCapability.class)
.getInterval()
.equals(MenuConstants.latLonIntervals[0])) {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = true;
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).setInterval(
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class)
.getInterval());
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).setInterval(
MenuConstants.latLonIntervals[0]);
}
}
getTopMostSelectedResource().getCapability(
CylindricalCedCapability.class).setCylindrical(cylind);
}
getContainer().refresh();
}
}
}
/*
* (non-Javadoc)
@ -175,4 +214,3 @@ public class CylindricalCedAction extends AbstractRightClickAction
}
}

View file

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
/**
* TODO Add Description
* implementation for describing persistable capabilities
*
* <pre>
*
@ -42,7 +42,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
@XmlAccessorType(XmlAccessType.NONE)
public class CylindricalCedCapability extends AbstractCapability {
private String cylind = "No Projection";
private String cylind = MenuConstants.projections[0];
/**
* @return the outlineWidth
@ -62,7 +62,6 @@ public class CylindricalCedCapability extends AbstractCapability {
}
}
@Override
public AbstractCapability clone() {
CylindricalCedCapability oc = new CylindricalCedCapability();

View file

@ -0,0 +1,28 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.actions;
/**
* implementation for describing persistable capabilities
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 01/22/2014 958 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class MenuConstants {
public static final String[] latLonIntervals = { "No Overlay", "10", "15",
"30", "45", "60" };
public static final String[] projections = { "Normal", "Stonyhurst",
"Carrington" };
private MenuConstants() {
}
}

View file

@ -1,5 +1,7 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.actions;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
@ -7,14 +9,12 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import gov.noaa.nws.ncep.viz.rsc.solarimage.rsc.SolarImageResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
/**
*
* Enable/Disable LatLon Overlay for SolarImageResource
* Enable/Disable stonyhurst LatLon Overlay for SolarImageResource
*
* <pre>
*
@ -23,19 +23,18 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 21, 2013 958 qzhou Initial Creation.
*
* 12/17/2013 958 qzhou Fixed cylind and latlon context menu leftover problem
* 01/22/2014 1046 qzhou Move enum to MenuConstants
* </pre>
*
* @author qzhou
* @version 1
*/
public class StonyLatLonAction extends AbstractRightClickAction
implements IMenuCreator {
private Menu menu;
private static String[] latLonIntervals = {"No Overlay", "10", "15", "30", "45", "60"};
public class StonyLatLonAction extends AbstractRightClickAction implements
IMenuCreator {
private Menu menu;
/**
* Default constructor.
@ -50,7 +49,6 @@ public class StonyLatLonAction extends AbstractRightClickAction
return this;
}
@Override
public void dispose() {
if (menu != null) {
@ -80,45 +78,50 @@ public class StonyLatLonAction extends AbstractRightClickAction
}
public void fillMenu(Menu menu, Display d) {
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentInterval = getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).getInterval();
for (String intvl : latLonIntervals) {
boolean selected = intvl.equals(currentInterval);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, intvl, d, selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, currentInterval, d, true));
actionItem.fill(menu, -1);
}
}
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof SolarImageResource) {
boolean found = false;
String currentInterval = getTopMostSelectedResource()
.getCapability(StonyLatLonCapability.class).getInterval();
for (String intvl : MenuConstants.latLonIntervals) {
boolean selected = intvl.equals(currentInterval);
found |= selected;
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc, intvl, d,
selected));
actionItem.fill(menu, -1);
}
if (!found) {
ActionContributionItem actionItem = new ActionContributionItem(
new ChangeLatLonIntervalInternalAction(rsc,
currentInterval, d, true));
actionItem.fill(menu, -1);
}
}
}
private class ChangeLatLonIntervalInternalAction extends Action {
private String interval;
AbstractVizResource<?, ?> resource = null;
public ChangeLatLonIntervalInternalAction(AbstractVizResource<?, ?> resource, String intvl, Display d, boolean selected) {
public ChangeLatLonIntervalInternalAction(
AbstractVizResource<?, ?> resource, String intvl, Display d,
boolean selected) {
super(intvl);
this.resource = resource;
this.interval = intvl;
this.setChecked(false);
this.interval = intvl;
this.setChecked(false);
if (selected) {
this.setChecked(true);
}
//CarrLatLonAciton
this.setChecked(true);
}
// CarrLatLonAciton
}
/*
@ -138,24 +141,40 @@ public class StonyLatLonAction extends AbstractRightClickAction
*/
@Override
public void run() {
if (interval != null) {
if (this.getText().equals("No Overlay")) {
((SolarImageResource) resource).setLatLonOverlay(false);
((SolarImageResource) resource).isCarrington = false;
}
else {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = false;
}
getTopMostSelectedResource().getCapability(StonyLatLonCapability.class).setInterval(interval);
getTopMostSelectedResource().getCapability(CarrLatLonCapability.class).setInterval("No Overlay");
}
if (interval != null) {
if (this.getText().equals(MenuConstants.latLonIntervals[0])) {
if (getTopMostSelectedResource()
.getCapability(CarrLatLonCapability.class)
.getInterval()
.equals(MenuConstants.latLonIntervals[0])) {
((SolarImageResource) resource).setLatLonOverlay(false);
((SolarImageResource) resource).isCarrington = false;
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).setInterval(
interval);
}
} else {
if (!getTopMostSelectedResource()
.getCapability(CylindricalCedCapability.class)
.getCylind().equals(MenuConstants.projections[2])) {
((SolarImageResource) resource).setLatLonOverlay(true);
((SolarImageResource) resource).isCarrington = false;
getTopMostSelectedResource().getCapability(
StonyLatLonCapability.class).setInterval(
interval);
getTopMostSelectedResource().getCapability(
CarrLatLonCapability.class).setInterval(
MenuConstants.latLonIntervals[0]);
}
}
}
getContainer().refresh();
}
}
}
/*
* (non-Javadoc)
@ -168,4 +187,3 @@ public class StonyLatLonAction extends AbstractRightClickAction
}
}

View file

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
/**
* TODO Add Description
* implementation for describing persistable capabilities
*
* <pre>
*
@ -42,7 +42,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
@XmlAccessorType(XmlAccessType.NONE)
public class StonyLatLonCapability extends AbstractCapability {
private String interval = "No Overlay";
private String interval = MenuConstants.latLonIntervals[0];
/**
* @return the outlineWidth
@ -62,7 +62,6 @@ public class StonyLatLonCapability extends AbstractCapability {
}
}
@Override
public AbstractCapability clone() {
StonyLatLonCapability oc = new StonyLatLonCapability();

View file

@ -29,16 +29,27 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.style.MatchCriteria;
import com.raytheon.uf.common.style.StyleException;
//import com.raytheon.uf.common.*;
/**
* Match criteria in styleRule
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 01/22/2014 958 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "solarImageMatches")
public class SolarImageMatchCriteria extends MatchCriteria {
// private static final String INSTRUMENT = "instrument";
//
// private static final String WAVELENGTH = "wavelength";
//
// private static final String INT_TIME = "intTime";
@XmlElement
private String instrument;
@ -74,35 +85,59 @@ public class SolarImageMatchCriteria extends MatchCriteria {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.style.MatchCriteria#matches(com.raytheon
* .uf.common.style.MatchCriteria)
* @see com.raytheon.uf.common.style.MatchCriteria#matches(com.raytheon .uf.
* viz.core.style.MatchCriteria)
*/
@Override
public int matches(MatchCriteria aCriteria) throws StyleException {
int rval = -1;
if (aCriteria instanceof SolarImageMatchCriteria) {
rval = 0;
SolarImageMatchCriteria criteria = (SolarImageMatchCriteria) aCriteria;
if (instrument != null
&& instrument.equalsIgnoreCase(criteria.instrument)) {
rval++;
}
if (intTime != null && intTime.equalsIgnoreCase(criteria.intTime)) {
&& (instrument.contains(criteria.instrument) || (criteria.instrument != null && criteria.instrument
.contains(instrument)))) {
rval++;
}
if (wavelength != null
&& wavelength.equalsIgnoreCase(criteria.wavelength)) {
rval++;
}
if (intTime != null && intTime.equalsIgnoreCase(criteria.intTime)) {
rval++;
}
/*
* if (detector != null &&
* detector.equalsIgnoreCase(criteria.detector)) { rval++; }
*/
if (rval == getTotalNotNullValues()) {
rval = 1;
} else {
rval = 0;
}
}
return rval;
}
public int getTotalNotNullValues() throws StyleException {
int tval = 0;
if (instrument != null)
tval++;
if (wavelength != null)
tval++;
if (intTime != null)
tval++;
return tval;
}
/**
* @return the wavelength
*/

View file

@ -1,573 +0,0 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.CylindCedDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.LogCylindCedDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.LogSolarImageDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.SolarImageDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.HeaderData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.CSConversions;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.CylindricalConverter;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.WCSConverter;
import java.awt.geom.AffineTransform;
import java.text.DecimalFormat;
import java.util.LinkedHashMap;
import java.util.Map;
import nom.tam.fits.Header;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.referencing.operation.transform.AffineTransform2D;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.xy.graph.GraphProperties;
import com.raytheon.uf.common.style.image.DataScale;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Display Cylindrical
*
* <pre>
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/01/2013 958 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class CylindCedDisplay implements IRenderable {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CylindCedDisplay.class);
private IImage image = null;
private IImage cylindImage = null;
private float brightness = 1.0f;
private float contrast = 1.0f;
private boolean isInterpolated = true;
private final SolarImageRecord record;
private CylindCedDataCallback dataCallback;
private SolarImageDataCallback solarDataCallback;
private ColorMapParameters colorMapParameters;
private boolean isColorMapChanged = false;
private final GeneralGridGeometry gridGeom;
private final boolean logConvert;
private WCSConverter transformOld;
private CylindricalConverter transform;
private AffineTransform at;
private MathTransform worldToPixel;
private MathTransform pixelToWorld;
private double scale;
private PixelCoverage extent = null;
private ImageData imageData;
private ImageData cylindImageData;
private final HeaderData headerData;
private final Header header;
private final CSConversions csConv;
private final int nx;
private final int ny;
private final double hgln;
private final double crln;
private final double L0;
private DataScale dataScale = null;
private int cylindrical = 0; // 0--no cylindrical, 1--stony, 2--carrington
private boolean isCarr = false;
private int status = 0;
public CylindCedDisplay(SolarImageRecord rec, ColorMapParameters cmp,
GeneralGridGeometry gridGeometry, boolean logConvert,
DataScale dataScale, int cylindrical, int latLonInterval)
throws VizException {
this.record = rec;
this.colorMapParameters = cmp;
this.gridGeom = gridGeometry;
this.logConvert = logConvert;
this.dataScale = dataScale;
this.cylindrical = cylindrical;
status = 0;
if (this.logConvert) {
solarDataCallback = new LogSolarImageDataCallback(record);
imageData = solarDataCallback.getImageData();
} else {
solarDataCallback = new SolarImageDataCallback(record);
imageData = solarDataCallback.getImageData();
}
header = imageData.getHeader();
headerData = new HeaderData(record);
csConv = new CSConversions(headerData);
nx = headerData.getNx();
ny = headerData.getNy();
hgln = headerData.getHgln();
crln = headerData.getCrln();
L0 = headerData.getL0();
// System.out.println("Angles "+hgln+" " +crln+" " +L0);
}
@Override
public void paint(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
// old image
if (image == null) {// || isColorMapChanged) {
image = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(solarDataCallback, colorMapParameters);
if (image.getStatus().equals("UNLOADED")) {
image.stage();
}
}
if (transformOld == null) {
try {
transformOld = new WCSConverter(header);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
throw new VizException(
"Could not create image to world coordinate transform",
e);
}
}
// create new image
if (status != cylindrical) {
this.status = cylindrical;
cylindImageData = getNewImageData(paintProps);// , imageData);
if (this.logConvert) {
dataCallback = new LogCylindCedDataCallback(record,
cylindImageData);
} else {
dataCallback = new CylindCedDataCallback(record,
cylindImageData);
}
}
// if (image == null || isColorMapChanged){
float scaleMin = dataScale.getMinValue().floatValue();
float scaleMax = dataScale.getMaxValue().floatValue();
float range = scaleMax - scaleMin;
float cMapMax = (float) (range / 255.0)
* colorMapParameters.getColorMapMax();
float cMapMin = (float) (range / 255.0)
* colorMapParameters.getColorMapMin();
if (range <= 255.0) {
if ((colorMapParameters.getColorMapMax() > range)) {
colorMapParameters.setColorMapMax(cMapMax);
}
if ((colorMapParameters.getColorMapMin() > range)) {
colorMapParameters.setColorMapMin(cMapMin);
}
}
else {
if (scaleMin >= 0) {
if ((colorMapParameters.getColorMapMax() >= 0)
&& (cMapMax <= range)) {
colorMapParameters.setColorMapMax(cMapMax);
}
if ((colorMapParameters.getColorMapMin() >= 0)
&& (cMapMin <= range)) {
colorMapParameters.setColorMapMin(cMapMin);
}
} else {
if ((colorMapParameters.getColorMapMax() >= 0)
&& (cMapMax <= range)) {
colorMapParameters.setColorMapMax(cMapMax - scaleMax);
}
if ((colorMapParameters.getColorMapMin() >= 0)
&& (cMapMin <= range)) {
colorMapParameters.setColorMapMin(cMapMin - scaleMax);
}
}
}
if ((cylindImage == null) || isColorMapChanged) {
cylindImage = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(dataCallback, colorMapParameters);
// }
}
if ((transform == null) || (extent == null)) {
try {
transform = new CylindricalConverter();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
throw new VizException(
"Could not create image to world coordinate transform",
e);
}
// double[] ll = new double[] { -180, -90 };
// double[] lr = new double[] {180, -90};
// double[] ur = new double[] {180, 90};
// double[] ul = new double[] {-180, 90};
double[] ll = transform.imageToWorld(new double[] { 0, 0 });
double[] lr = transform.imageToWorld(new double[] { 360, 0 });
double[] ur = transform.imageToWorld(new double[] { 360, 180 });
double[] ul = transform.imageToWorld(new double[] { 0, 180 });
double minX = Math.min(ll[0], ul[0]);
double maxX = Math.max(lr[0], ur[0]);
double minY = Math.min(ll[1], lr[1]);
double maxY = Math.max(ul[1], ur[1]);
if ((maxX - minX) > (maxY - minY)) {
scale = gridGeom.getEnvelope().getSpan(0) / (maxX - minX);
} else {
scale = gridGeom.getEnvelope().getSpan(1) / (maxY - minY);
}
double[] center = new double[2];
if (paintProps instanceof GraphProperties) {
center = ((GraphProperties) paintProps).getWorldExtent()
.getCenter();
} else {
center = paintProps.getView().getExtent().getCenter();
}
center[0] = gridGeom.getEnvelope().getMedian(0);
center[1] = gridGeom.getEnvelope().getMedian(1);
double[] llp = new double[2];
double[] lrp = new double[2];
double[] ulp = new double[2];
double[] urp = new double[2];
try {
at = AffineTransform.getTranslateInstance(center[0], center[1]);
at.concatenate(AffineTransform.getScaleInstance(scale, -scale));
worldToPixel = new AffineTransform2D(at);
pixelToWorld = worldToPixel.inverse();
// System.out.println(pixelToWorld.toWKT());
worldToPixel.transform(ll, 0, llp, 0, 1);
worldToPixel.transform(lr, 0, lrp, 0, 1);
worldToPixel.transform(ul, 0, ulp, 0, 1);
worldToPixel.transform(ur, 0, urp, 0, 1);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
throw new VizException(
"Could not create pixel extent for image", e);
}
extent = new PixelCoverage(new Coordinate(ulp[0], ulp[1]),
new Coordinate(urp[0], urp[1]), new Coordinate(lrp[0],
lrp[1]), new Coordinate(llp[0], llp[1]));
// System.out.println("**** cylinextent "+ulp[0]+" "+ ulp[1]
// +" "+urp[0]+" "+ urp[1]+" "+ lrp[0]+" "+lrp[1]+" "+
// llp[0]+" "+llp[1] +" "+scale);
}
cylindImage.setContrast(contrast);
cylindImage.setBrightness(brightness);
cylindImage.setInterpolated(isInterpolated);
target.drawRaster(cylindImage, extent, paintProps);
}
public ImageData getNewImageData(PaintProperties paintProps) {
ImageData newImageData = null;
try {
newImageData = new ImageData(record);
newImageData.setNx(360);
newImageData.setNy(180);
} catch (VizException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
float[][] newImgArray = new float[360][180]; // lat, lon
double[] centric = new double[2];
int primeMeridian = 0; // related to the center of the image
if (cylindrical == 2) {
isCarr = true;
} else {
isCarr = false;
}
if (cylindrical == 2) {
if (crln != 0) {
primeMeridian = 180 + (int) crln; // Canvas started from -180
} else {
primeMeridian = 180 + (int) (L0 + hgln);
}
if (primeMeridian < 360) {
primeMeridian = primeMeridian + 360;
}
if (primeMeridian > 360) {
primeMeridian = primeMeridian - 360;
}
} else if (cylindrical == 1) {
primeMeridian = 180 + (int) hgln; // Canvas started from -180
}
for (int i = 0; i < 360; i++) {
for (int j = 0; j < 180; j++) {
if (((i >= (primeMeridian - 90)) && (i <= (primeMeridian + 90)))
|| (((primeMeridian + 90) > 360) && (i >= 0) && (i < ((primeMeridian + 90) - 360)))
|| (((primeMeridian - 90) < 0) && (i <= 360) && (i > ((primeMeridian - 90) + 360)))) {
double[] latlon = new double[] { i - 180, j - 90 };
centric = (new CSConversions(headerData))
.heliographicToHeliocentric(latlon, isCarr);
double img[] = transformOld.WorldToImage(centric);
// remember that image was flipped during earlier and stored
// with first pixel as top left
// try {
// headerData = new HeaderData(record);
// } catch (VizException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
img[1] = ny - 1 - img[1];
// double val = getImageValue((int) (img[0]), (int) img[1]);
double val = getImageValue((int) (Math.round(img[0])),
(int) (Math.round(img[1])));
double imgVal = logConvert ? new Double(Math.pow(10.0,
formatValue(val))) : val;
newImgArray[i][j] = (float) (imgVal);
}
else if (headerData.isSdoHmi()) { // hmi default is not 0
newImgArray[i][j] = (-1500);
}
}
}
int n = 0;
float[] imgDataRec = new float[360 * 180];
for (int j = 180 - 1; j >= 0; j--) { // Reverse order of rows
for (int i = 0; i < 360; i++) {
imgDataRec[n++] = newImgArray[i][j];
}
}
newImageData.setImageArrays(newImgArray);
newImageData.setImageValues(imgDataRec);
return newImageData;
}
public void dispose() {
if (this.image != null) {
this.image.dispose();
}
if (this.cylindImage != null) {
this.cylindImage.dispose();
}
}
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
Map<String, Object> map = new LinkedHashMap<String, Object>();
try {
double[] pixel = new double[] { coord.asLatLon().x,
coord.asLatLon().y };
double[] world = new double[2];
pixelToWorld.transform(pixel, 0, world, 0, 1); // now hcc is latlon
map.put("HCC", new Coordinate(formatValue(world[0]),
formatValue(world[1])));// move down
double image[] = transform.WorldToImage(world);
// remember that image was flipped during earlier and stored with
// first pixel as top left
image[1] = ny - 1 - image[1];
map.put("Image", new Coordinate(formatValue(image[0]),
formatValue(image[1])));
if (cylindrical == 1) {
map.put("StonyHurst", new Coordinate(formatValue(world[0]),
formatValue(world[1])));
} else if (cylindrical == 2) {
map.put("StonyHurst", new Coordinate(formatValue(world[0]),
formatValue(world[1])));
// double[] locWorld = new double [2];
// if (cylindrical ==1 ) {
// locWorld[0] = world[0];
// locWorld[1] = world[1];
// map.put("StonyHurst", new
// Coordinate(formatValue(locWorld[0]),
// formatValue(locWorld[1])));
// //map.put("Carrington", new
// Coordinate(formatValue(locWorld[0]+L0),
// formatValue(locWorld[1])));
// }
//
// if (cylindrical ==2 ) {
// locWorld[0] = world[0];
// locWorld[1] = world[1];
// map.put("Carrington", new
// Coordinate(formatValue(locWorld[0]),
// formatValue(locWorld[1])));
// //map.put("StonyHurst", new
// Coordinate(formatValue(locWorld[0]-L0),
// formatValue(locWorld[1])));
// }
}
long x = Math.round(image[0]);
long y = Math.round(image[1]);
double val = getImageValue((int) x, (int) y);
map.put("Display Value", new Double(formatValue(val)));
map.put("Data Value",
new Double(formatValue(dataCallback.getOriginalValue(val))));
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return map;
}
public double formatValue(double val) {
DecimalFormat df = new DecimalFormat("#.#####");
double newVal = val;
try {
String valStr = df.format(val);
Double valDbl = Double.parseDouble(valStr);
newVal = valDbl;
} catch (Exception e) {
return val;
}
return newVal;
}
public double getImageValue(int x, int y) {
double value = Float.NaN;
if (isInImageRange(x, y)) {
if (image instanceof IColormappedImage) {
value = ((IColormappedImage) image).getValue(x, y);
}
}
return value;
}
private boolean isInImageRange(int x, int y) {
return (x >= 0) && (x < nx) && (y >= 0) && (y < ny);
}
public void setBrightness(float brightness) {
this.brightness = brightness;
}
public void setContrast(float contrast) {
this.contrast = contrast;
}
public void setInterpolationState(boolean isInterpolated) {
this.isInterpolated = isInterpolated;
}
public void setColorMapParameters(ColorMapParameters params) {
this.colorMapParameters = params;
this.isColorMapChanged = true;
}
public void setColorMapChanged(boolean val) {
this.isColorMapChanged = val;
;
}
public PixelCoverage getPixelCoverage() {
return extent;
}
public MathTransform getWorldToPixel() {
return worldToPixel;
}
public CSConversions getCSConversions() {
return csConv;
}
public HeaderData getHeaderData() {
return headerData;
}
public void setCylindrical(int cylindrical) {
this.cylindrical = cylindrical;
;
}
public int getCylindrical() {
return cylindrical;
}
}

View file

@ -1,33 +1,16 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.viz.core.exception.VizException;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData;
import gov.noaa.nws.ncep.viz.resources.attributes.AbstractEditResourceAttrsInteractiveDialog;
import gov.noaa.nws.ncep.viz.resources.attributes.AbstractEditResourceAttrsDialog;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceAttrSet.RscAttrValue;
import gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarFromColorMapAttrsEditorComposite;
import gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarEditor;
import gov.noaa.nws.ncep.viz.ui.display.ColorBarFromColormap;
import gov.noaa.nws.ncep.viz.common.ColorMapUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
/**
* An interface to edit Solar resource attributes.
* An interface to edit Solar resource attributes.
*
* <pre>
* SOFTWARE HISTORY
@ -41,40 +24,43 @@ import gov.noaa.nws.ncep.viz.common.ColorMapUtil;
* @version 1
*/
public class EditSolarImageAttrsDialog extends AbstractEditResourceAttrsInteractiveDialog {
public EditSolarImageAttrsDialog(Shell parentShell, INatlCntrsResourceData r, Boolean apply) {
super(parentShell, r, apply);
resourceData = r;
// TODO Auto-generated constructor stub
}
public class EditSolarImageAttrsDialog extends
AbstractEditResourceAttrsInteractiveDialog {
public EditSolarImageAttrsDialog(Shell parentShell,
INatlCntrsResourceData r, Boolean apply) {
super(parentShell, r, apply);
resourceData = r;
// TODO Auto-generated constructor stub
}
private INatlCntrsResourceData resourceData;
private ColorBarFromColorMapAttrsEditorComposite cBarComposite= null;
//
@Override
public Composite createDialog( Composite topComp ) {
private ColorBarFromColorMapAttrsEditorComposite cBarComposite = null;
//
@Override
public Composite createDialog(Composite topComp) {
FormLayout layout0 = new FormLayout();
topComp.setLayout(layout0);
cBarComposite= new ColorBarFromColorMapAttrsEditorComposite(topComp, SWT.NONE,resourceData);
cBarComposite = new ColorBarFromColorMapAttrsEditorComposite(topComp,
SWT.NONE, resourceData);
return topComp;
}
@Override
public void initWidgets() {
// done in createDialog
}
@Override
protected void dispose() {
super.dispose();
if ( cBarComposite != null)
cBarComposite.dispose();
}
@Override
public void initWidgets() {
// done in createDialog
}
@Override
protected void dispose() {
super.dispose();
if (cBarComposite != null)
cBarComposite.dispose();
}
}

View file

@ -1,517 +0,0 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.HeaderData;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Coordinate;
/**
* The class that draws the latitude and longitude overlays.
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/04/2013 958 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class LatLonCylindOverlay {
// Latitude lines
private IWireframeShape[] wireframeShapeForLatLineArray;
private List<Coordinate[]> latCoordPointArrayList;
private IWireframeShape[] wireframeShapeForLonLineArray;
private List<Coordinate[]> lonCoordPointArrayList;
private double latLonDrawingPointInterval = 1.0;
protected int latLonInterval;
private CylindCedDisplay imageDisplay;
HeaderData headerData;
private IDescriptor descriptor;
private PaintProperties paintProps;
private float zoomFactor;
private double mapMinX;
private double mapMaxY;
private double mapMinY;
private double mapMaxX;
private double viewMinX;
private double viewMaxY;
private double viewMinY;
private double viewMaxX;
/*
* The four minimum and maximum of X and Y used to paint label
*/
private double effectiveMinX;
private double effectiveMaxY;
private double effectiveMinY;
private double effectiveMaxX;
boolean isCarrington;
public LatLonCylindOverlay(CylindCedDisplay imageDisplay, IDescriptor descriptor, int latLonInterval, PaintProperties paintProps) {
this.imageDisplay = imageDisplay;
this.descriptor = descriptor;
this.latLonInterval = latLonInterval;
this.paintProps = paintProps;
this.zoomFactor = paintProps.getZoomLevel();
// initializeMapMinAndMaxXAndY();
}
private void initializeMapMinAndMaxXAndY() {
mapMinX = descriptor.getGridGeometry().getGridRange().getLow(0);
mapMaxX = descriptor.getGridGeometry().getGridRange().getHigh(0);
mapMinY = descriptor.getGridGeometry().getGridRange().getLow(1);
mapMaxY = descriptor.getGridGeometry().getGridRange().getHigh(1);
}
private void initializeViewMinAndMaxXAndY() {
viewMinX = paintProps.getView().getExtent().getMinX();
viewMaxX = paintProps.getView().getExtent().getMaxX();
viewMinY = paintProps.getView().getExtent().getMinY();
viewMaxY = paintProps.getView().getExtent().getMaxY();
effectiveMinX = viewMinX;
effectiveMaxX = viewMaxX;
effectiveMinY = viewMinY;
effectiveMaxY = viewMaxY;
//System.out.println(" *** viewMinX = " + viewMinX + " " + viewMaxX + " " + viewMinY + " " + viewMaxY);
}
public void drawLatLines(IGraphicsTarget target) throws VizException, TransformException {
IFont.Style [] fontStyle = new IFont.Style[1];
fontStyle[0] = IFont.Style.BOLD;
IFont labelFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 12, fontStyle);
labelFont.setSmoothing(false);
labelFont.setScaleFont(false);
initializeViewMinAndMaxXAndY();
int latDrawingLineNumber = getLatDrawingLineNumber(latLonInterval);
latCoordPointArrayList = new ArrayList<Coordinate[]>(latDrawingLineNumber);
wireframeShapeForLatLineArray = new IWireframeShape[latDrawingLineNumber];
int latValue = -90;
for(int i=0; i<wireframeShapeForLatLineArray.length && latValue<= 90; i++) {
wireframeShapeForLatLineArray[i] = target.createWireframeShape(false, descriptor);
Coordinate[] latLonCoordArray = createCoordArrayForLatLine(imageDisplay, latValue, latLonDrawingPointInterval);
if (latLonCoordArray !=null) {
latCoordPointArrayList.add(latLonCoordArray);
wireframeShapeForLatLineArray[i].addLineSegment(latLonCoordArray);
wireframeShapeForLatLineArray[i].compile();
}
latValue += latLonInterval;
}
latValue = -90;
for(int i=0; i<wireframeShapeForLatLineArray.length && latValue<= 90; i++) {
wireframeShapeForLatLineArray[i].clearLabels();
addDefaultLabelByPointIndex(wireframeShapeForLatLineArray[i], String.valueOf((int)latValue), latCoordPointArrayList.get(i), 0);
updateEffectiveMinX(getMapMinX(), getViewMinX(), getViewMaxX());
int pointIndexForAddingLabel = getPointLabelIndexForAddingLatLabel(latCoordPointArrayList.get(i), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(), getEffectiveMaxY());
if(!(pointIndexForAddingLabel < 0))
addLabelOnLatLine( wireframeShapeForLatLineArray[i], latCoordPointArrayList.get(i), pointIndexForAddingLabel,
String.valueOf((int)latValue));
target.drawWireframeShape(wireframeShapeForLatLineArray[i],
new RGB(255, 0, 0),
1.0f,
LineStyle.MEDIUM_DASHED, labelFont);
latValue += latLonInterval;
}
}
public void drawLonLines(IGraphicsTarget target) throws VizException, TransformException {
IFont.Style [] fontStyle = new IFont.Style[1];
fontStyle[0] = IFont.Style.BOLD;
IFont labelFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 12, fontStyle);
labelFont.setSmoothing(false);
labelFont.setScaleFont(false);
int lonDrawingLineNumber = getLonDrawingLineNumber(latLonInterval);
lonCoordPointArrayList = new ArrayList<Coordinate[]>(lonDrawingLineNumber);
wireframeShapeForLonLineArray = new IWireframeShape[lonDrawingLineNumber];
int lonValue = -180; // 180 will not be displayed
for (int i=0; i<wireframeShapeForLonLineArray.length && lonValue <= 180; i++) {
wireframeShapeForLonLineArray[i] = target.createWireframeShape(false, descriptor);
Coordinate[] latLonCoordArray = createCoordArrayForLonLine(imageDisplay, lonValue, latLonDrawingPointInterval);
lonCoordPointArrayList.add(latLonCoordArray);
wireframeShapeForLonLineArray[i].addLineSegment(latLonCoordArray);
wireframeShapeForLonLineArray[i].compile();
lonValue += latLonInterval;
}
lonValue = -180;
for (int i=0; i<wireframeShapeForLonLineArray.length && lonValue <= 180 ; i++) {
wireframeShapeForLonLineArray[i].clearLabels();
updateEffectiveMaxY(getMapMaxY(), getViewMinY(), getViewMaxY());
int pointIndexForAddingLabel = getPointLabelIndexForAddingLonLabel(lonCoordPointArrayList.get(i), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(), getEffectiveMaxY());
if(!(pointIndexForAddingLabel+1 < 0))
addLabelOnLonLine(wireframeShapeForLonLineArray[i], lonCoordPointArrayList.get(i), pointIndexForAddingLabel+1, //-1
String.valueOf(lonValue));
target.drawWireframeShape(wireframeShapeForLonLineArray[i],
new RGB(255, 0, 0),
1.0f,
LineStyle.MEDIUM_DASHED, labelFont);
lonValue += latLonInterval;
}
// won't draw on 180
wireframeShapeForLonLineArray[0] = target.createWireframeShape(false, descriptor);
Coordinate[] latLonCoordArray = createCoordArrayForLonLine(imageDisplay, -179.4, latLonDrawingPointInterval);
lonCoordPointArrayList.add(latLonCoordArray);
wireframeShapeForLonLineArray[0].addLineSegment(latLonCoordArray);
wireframeShapeForLonLineArray[0].compile();
wireframeShapeForLonLineArray[0].clearLabels();
updateEffectiveMaxY(getMapMaxY(), getViewMinY(), getViewMaxY());
int pointIndexForAddingLabel = getPointLabelIndexForAddingLonLabel(lonCoordPointArrayList.get(0), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(), getEffectiveMaxY());
addLabelOnLonLine(wireframeShapeForLonLineArray[0], lonCoordPointArrayList.get(0), pointIndexForAddingLabel+1, //-1
String.valueOf(-180));
target.drawWireframeShape(wireframeShapeForLonLineArray[0],
new RGB(255, 0, 0),
1.0f,
LineStyle.MEDIUM_DASHED, labelFont);
wireframeShapeForLonLineArray[0] = target.createWireframeShape(false, descriptor);
latLonCoordArray = createCoordArrayForLonLine(imageDisplay, 179.4, latLonDrawingPointInterval); //180 won't draw
lonCoordPointArrayList.add(latLonCoordArray);
wireframeShapeForLonLineArray[0].addLineSegment(latLonCoordArray);
wireframeShapeForLonLineArray[0].compile();
wireframeShapeForLonLineArray[0].clearLabels();
updateEffectiveMaxY(getMapMaxY(), getViewMinY(), getViewMaxY());
pointIndexForAddingLabel = getPointLabelIndexForAddingLonLabel(lonCoordPointArrayList.get(0), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(), getEffectiveMaxY());
addLabelOnLonLine(wireframeShapeForLonLineArray[0], lonCoordPointArrayList.get(360/latLonInterval), pointIndexForAddingLabel+1, //-1
String.valueOf(180));
target.drawWireframeShape(wireframeShapeForLonLineArray[0],
new RGB(255, 0, 0),
1.0f,
LineStyle.MEDIUM_DASHED, labelFont);
}
private Coordinate[] createCoordArrayForLatLine(CylindCedDisplay imageDisplay, double latValue, double latLonPointInterval) throws VizException {
int coordArrayLength = (int)(360 / latLonPointInterval) + 1;
Coordinate[] coordArray = new Coordinate[coordArrayLength];
Coordinate[] coordPixelArray = new Coordinate[coordArrayLength];
double lon = -180;
for(int i=0; i<coordArray.length && lon <= 180; i++) {
coordArray[i] = new Coordinate(lon, latValue);
double[] coord = new double[2];
coord[0] = coordArray[i].x;
coord[1] = coordArray[i].y;
double[] pixel = new double[2];
try {
imageDisplay.getWorldToPixel().transform(coord, 0, pixel, 0, 1);
} catch (TransformException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
coordPixelArray[i] = new Coordinate(pixel[0], pixel[1]);//latLon;
lon += latLonPointInterval;
}
return coordPixelArray;
}
private Coordinate[] createCoordArrayForLonLine(CylindCedDisplay imageDisplay,double lonValue, double latLonPointInterval) throws VizException {
int coordArrayLength = (int)(180 / latLonPointInterval) ;//+1;
Coordinate[] coordArray = new Coordinate[coordArrayLength];
Coordinate[] coordPixelArray = new Coordinate[coordArrayLength];
double lat = -90; //+ latLonPointInterval;
for(int i=0; i<coordArray.length && lat <= 90; i++) {
coordArray[i] = new Coordinate(lonValue, lat);
double[] coord = new double[2];
coord[0] = coordArray[i].x;
coord[1] = coordArray[i].y;
double[] pixel = new double[2];
try {
imageDisplay.getWorldToPixel().transform(coord, 0, pixel, 0, 1);
} catch (TransformException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
coordPixelArray[i] = new Coordinate(pixel[0],pixel[1]);
lat += latLonPointInterval;
}
return coordPixelArray;
}
private int getLatDrawingLineNumber(int latInterval) {
int latLineNumber = 180/15; // set a default value
if(latInterval>0 && latInterval<=180) {
latLineNumber = 180/latInterval;
}
return latLineNumber + 1;
}
private int getLonDrawingLineNumber(int lonInterval) {
int lonLineNumber = 360/15; // set a default value
if(lonInterval>0 && lonInterval<=360) {
lonLineNumber = 360 / lonInterval;
if(lonLineNumber > 360)
lonLineNumber = 360; // if we draw 360 lines, the last line will overlap with the first line
}
return lonLineNumber + 1;
}
private void addDefaultLabelByPointIndex(IWireframeShape wireframeShape, String labelValue,
Coordinate[] latLonCoordinateArray, int defaultPointIndex) throws TransformException {
double[] tmp = { latLonCoordinateArray[defaultPointIndex].x, latLonCoordinateArray[defaultPointIndex].y};
double[] screenPixel = descriptor.worldToPixel(tmp);//new double[2];
if(screenPixel != null)
wireframeShape.addLabel(labelValue, screenPixel);
}
private void addLabelOnLatLine( IWireframeShape wireframeShape, Coordinate[] coordinateArray, int coordiantePointIndex, String label) throws TransformException {
// if (coordiantePointIndex < 175) {
double[] tmp = { coordinateArray[coordiantePointIndex].x -20, coordinateArray[coordiantePointIndex].y};//move label down
double[] screenPixel = descriptor.worldToPixel(tmp);//new double[2];
//imageDisplay.getWorldToPixel().transform(tmp, 0, screenPixel, 0, 1);//descriptor.worldToPixel(tmp);
if(screenPixel != null) {
wireframeShape.clearLabels();
wireframeShape.addLabel(label, screenPixel);
}
// }
}
private void addLabelOnLonLine( IWireframeShape wireframeShape, Coordinate[] coordinateArray, int coordiantePointIndex, String label) throws TransformException {
// if (coordiantePointIndex < 175) {
double[] tmp = { coordinateArray[coordiantePointIndex].x, coordinateArray[coordiantePointIndex].y + 10};//move label down
double[] screenPixel = descriptor.worldToPixel(tmp);//new double[2];
//imageDisplay.getWorldToPixel().transform(tmp, 0, screenPixel, 0, 1);//descriptor.worldToPixel(tmp);
if(screenPixel != null) {
wireframeShape.clearLabels();
wireframeShape.addLabel(label, screenPixel);
}
// }
}
private int getPointLabelIndexForAddingLatLabel(Coordinate[] latLonCoordinateArray,
float zoomFactor, double minX, double maxX, double minY, double maxY) throws TransformException {
int pointIndex = -1;
if(latLonCoordinateArray == null || latLonCoordinateArray.length == 0)
return pointIndex;
double positionOffset = 0; //120 adjust label zooming appearance
for(int i=0; i<latLonCoordinateArray.length; i++) {
double[] tmp = { latLonCoordinateArray[i].x, latLonCoordinateArray[i].y};
double[] screenPixel = descriptor.worldToPixel(tmp);//new double[2];
//imageDisplay.getWorldToPixel().transform(tmp, 0, screenPixel, 0, 1);//descriptor.worldToPixel(tmp);
if(isPointForPlacingLatituteLabel(screenPixel, positionOffset, zoomFactor, minX, maxX, minY, maxY)) {
pointIndex = i;
break;
}
}
return pointIndex;
}
private int getPointLabelIndexForAddingLonLabel(Coordinate[] latLonCoordinateArray,
float zoomFactor, double minX, double maxX, double minY, double maxY) throws TransformException {
int pointIndex = -1;
if(latLonCoordinateArray == null || latLonCoordinateArray.length == 0)
return pointIndex;
double positionOffset = 0;
for(int i=0; i<latLonCoordinateArray.length; i++) {
double[] tmp = { latLonCoordinateArray[i].x, latLonCoordinateArray[i].y};
double[] screenPixel = descriptor.worldToPixel(tmp);// new double[2];
//imageDisplay.getWorldToPixel().transform(tmp, 0, screenPixel, 0, 1);//descriptor.worldToPixel(tmp);
if(isPointForPlacingLongituteLabel(screenPixel, positionOffset, zoomFactor, minX, maxX, minY, maxY)) {
pointIndex = i;
break;
}
}
return pointIndex;
}
private boolean isPointForPlacingLatituteLabel(double[] pixelValueArray, double positionOffset, float zoomFactor,
double minX, double maxX, double minY, double maxY) {
/* */ double delta = 200;
double adjustedOffset = positionOffset * zoomFactor;
boolean isPointForLabel = false;
if(pixelValueArray != null) {
if(pixelValueArray[0] > (minX + adjustedOffset) && pixelValueArray[0] < maxX &&
pixelValueArray[1] > minY && pixelValueArray[1] < maxY) {
if(Math.abs(pixelValueArray[0] - minX - (positionOffset * zoomFactor)) < delta) {
isPointForLabel = true;
}
}
}
return isPointForLabel;
}
private boolean isPointForPlacingLongituteLabel(double[] pixelValueArray, double positionOffset, float zoomFactor,
double minX, double maxX, double minY, double maxY) {
double delta = 20;
double adjustedOffset = positionOffset * zoomFactor;
boolean isPointForLabel = false;
if(pixelValueArray != null) {
if(pixelValueArray[0] > (minX-adjustedOffset) && pixelValueArray[0] < maxX &&
pixelValueArray[1] > minY && pixelValueArray[1] < maxY) {
if(Math.abs(pixelValueArray[1] + maxY-adjustedOffset) < delta) {
isPointForLabel = true;
}
}
}
return isPointForLabel;
}
private void updateEffectiveMinX(double mapMinXValue, double viewMinXValue, double viewMaxXValue) {
if(isLeftEdgeOfMapInsideCurrentView(mapMinXValue, viewMinXValue, viewMaxXValue)) {
effectiveMinX = mapMinXValue;
}
}
private boolean isLeftEdgeOfMapInsideCurrentView(double minXOfMap, double minXOfCurrentView, double maxXOfCurrentView) {
boolean isInsideResult = false;
if(minXOfMap > minXOfCurrentView && minXOfMap < maxXOfCurrentView)
isInsideResult = true;
return isInsideResult;
}
private void updateEffectiveMaxY(double mapMaxYValue, double viewMinYValue, double viewMaxYValue) {
if(isBottomEdgeOfMapInsideCurrentView(mapMaxYValue, viewMinYValue, viewMaxYValue))
effectiveMaxY = mapMaxYValue;
}
private boolean isBottomEdgeOfMapInsideCurrentView(double maxYOfMap, double minYOfCurrentView, double maxYOfCurrentView) {
boolean isInsideResult = false;
if(maxYOfMap > minYOfCurrentView && maxYOfMap < maxYOfCurrentView) {
isInsideResult = true;
}
return isInsideResult;
}
/*
* the getters for Map's Min and Max X and Y, View's Min and Max X and Y
*/
public double getViewMinX() {
return viewMinX;
}
public double getViewMaxY() {
return viewMaxY;
}
public double getViewMinY() {
return viewMinY;
}
public double getViewMaxX() {
return viewMaxX;
}
public double getMapMinX() {
return mapMinX;
}
public double getMapMaxY() {
return mapMaxY;
}
public double getMapMinY() {
return mapMinY;
}
public double getMapMaxX() {
return mapMaxX;
}
public double getEffectiveMinX() {
return effectiveMinX;
}
public double getEffectiveMaxY() {
return effectiveMaxY;
}
public double getEffectiveMinY() {
return effectiveMinY;
}
public double getEffectiveMaxX() {
return effectiveMaxX;
}
}

View file

@ -62,8 +62,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0
*/
public class Sampling {
public class Sampling {
/**
* The result of a hover operation: a set of strings and corresponding
* colors
@ -86,10 +86,10 @@ public class Sampling {
private VerticalAlignment verticalAlignment = VerticalAlignment.TOP;
public Sampling() {
public Sampling() {
}
protected SampleResult doHover(ReferencedCoordinate coord,
ResourceList resources) throws VizException {
SampleResult result = new SampleResult();
@ -97,10 +97,13 @@ public class Sampling {
List<RGB> colorList = new ArrayList<RGB>();
try {
int size = resources.size();
for (int i = size - 1; i >= 0; --i) {
ResourcePair rp = resources.get(i);
String retVal = recursiveHoverSearch(rp, coord);
if (retVal != null && retVal.length() > 0) {
RGB color = null;
if (rp.getResource().hasCapability(
ColorableCapability.class)) {
@ -120,11 +123,15 @@ public class Sampling {
colorList.add(color);
labelList.add(retVal.substring(p1));
}
break;
}
}
} catch (Throwable t) {
/*statusHandler.handle(Priority.PROBLEM, "Error sampling resources: "
+ t.getLocalizedMessage(), t);*/
/*
* statusHandler.handle(Priority.PROBLEM,
* "Error sampling resources: " + t.getLocalizedMessage(), t);
*/
}
result.labels = labelList.toArray(new String[labelList.size()]);
@ -150,15 +157,17 @@ public class Sampling {
}
protected void paintResult(IGraphicsTarget target, IDescriptor descriptor,
PaintProperties paintProps, ReferencedCoordinate coord) throws VizException {
hoverFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 10, null);
hoverFont.setSmoothing(false);
hoverFont.setScaleFont(false);
SampleResult result = doHover(coord, descriptor.getResourceList());
PaintProperties paintProps, ReferencedCoordinate coord)
throws VizException {
if (hoverFont == null) {
hoverFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 10, null);
hoverFont.setSmoothing(false);
hoverFont.setScaleFont(false);
}
SampleResult result = doHover(coord, descriptor.getResourceList());
verticalAlignment = VerticalAlignment.TOP;
target.clearClippingPlane();
try {
@ -244,13 +253,13 @@ public class Sampling {
}
errorInHovering = false;
} catch (Exception e) {
if (errorInHovering) {
// Keep down the number of error messages
/* statusHandler.handle(
Priority.PROBLEM,
"Error painting sample text: "
+ e.getLocalizedMessage(), e);*/
}
// if (errorInHovering) {
// // Keep down the number of error messages
// /*
// * statusHandler.handle( Priority.PROBLEM,
// * "Error painting sample text: " + e.getLocalizedMessage(), e);
// */
// }
errorInHovering = true;
}
}
@ -291,15 +300,13 @@ public class Sampling {
while (j < split.length) {
String s = split[j];
if (s.length() + line.length() <= approxLenPerStr) {
if (!s.isEmpty()){
if (j == split.length -1 && split[1].equalsIgnoreCase("="))
{
line = split[split.length-1];
}
else
{
line += " " + s;
}
if (!s.isEmpty()) {
if (j == split.length - 1
&& split[1].equalsIgnoreCase("=")) {
line = split[split.length - 1];
} else {
line += " " + s;
}
} else {
line += " ";
}
@ -318,7 +325,8 @@ public class Sampling {
alignments[i]);
if (alignment == alignments[i]
&& (targetAlignment == null || alignment == targetAlignment)) {
// the alignment was not changed and we are the target alignment, we are done
// the alignment was not changed and we are the target
// alignment, we are done
done = true;
} else {
if (targetAlignment == null) {
@ -445,5 +453,9 @@ public class Sampling {
return referencePoint;
}
public void dispose() {
if (hoverFont != null) {
hoverFont.dispose();
}
}
}

View file

@ -3,24 +3,24 @@ package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import gov.noaa.nws.ncep.viz.rsc.solarimage.LogSolarImageDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.SolarImageDataCallback;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.HeaderData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageData;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageFunctionParser;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.CSConversions;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.CylindricalConverter;
import gov.noaa.nws.ncep.viz.rsc.solarimage.wcs.WCSConverter;
import java.awt.geom.AffineTransform;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import nom.tam.fits.Header;
import java.util.TreeMap;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.referencing.operation.transform.AffineTransform2D;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
@ -28,10 +28,10 @@ import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.style.image.DataScale;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -41,6 +41,7 @@ import com.raytheon.uf.viz.xy.graph.GraphProperties;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Display the image
*
* <pre>
*
@ -51,6 +52,16 @@ import com.vividsolutions.jts.geom.Coordinate;
* 02/21/2013 958 qzhou, sgurung Initial creation
* 03/19/2013 958 qzhou, sgurung implemented colormap changing
* 03/28/2013 958 qzhou Added location adjusting for THEMATIC
* 11/04/2013 958 qzhou Refacted code and Combined CylindricalDisplay to here
* 11/07/2013 958 qzhou Fixed problems of sampling and latlon curve direction and North direction
* 11/27/2013 958 sgurung, qzhou Fix for OutOfMemoryError: get data from hdf5 one frame at a time during paint,
* combine callback classes (use same for normal and cylindrical)
* 12/31/2013 1046 qzhou Added image function feature.
* Added getFunctioningImageData. Fixed OutOfMemoryError for imageFunction.
* Added imgDifference, and work on poler rotated image differencing(4 types).
* Modified getImageValue. Modified paint.
* Solved transform reverse caused cylindrical image & sampling problems.
* 01/15/2013 958 qzhou Solved problem that looping on a lot frames, cylindrical image become normal image.
* </pre>
*
* @author qzhou, sgurung
@ -61,6 +72,8 @@ public class SolarImageDisplay implements IRenderable {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SolarImageDisplay.class);
private SolarImageRecord record;
private IImage image = null;
private float brightness = 1.0f;
@ -69,134 +82,99 @@ public class SolarImageDisplay implements IRenderable {
private boolean isInterpolated = true;
private final SolarImageRecord record;
private SolarImageDataCallback dataCallback;
private ColorMapParameters colorMapParameters;
private boolean isColorMapChanged = false;
private final GeneralGridGeometry gridGeom;
private final boolean logConvert;
private WCSConverter transform;
private CylindricalConverter transformCylin;
private PixelCoverage extent = null;
private AffineTransform at;
private MathTransform worldToPixel;
private MathTransform pixelToWorld;
private final HeaderData headerData;
private final Header header;
private final int nx;
private final int ny;
private final GeneralGridGeometry gridGeom;
private double scale;
private AffineTransform at;
protected CSConversions csConv = null;;
public CSConversions csConv;
private int cylindrical = 0; // 0--no cylindrical, 1--stony, 2--carrington
private DataScale dataScale = null;
// private boolean projectionChanged = false;
public List points = new ArrayList();
private boolean isCarr = false;
private ImageData imageData;
private boolean recreateLatLonOverlay = false;
boolean temflag = false;
private LatLonOverlay latLonOverlay;
public SolarImageDisplay(SolarImageRecord rec, ColorMapParameters cmp,
private int latLonInterval = 0; // 0, 15,30,45,60
private String imageFunction;
protected TreeMap<Long, SolarImageRecord> functioningRecordMap = new TreeMap<Long, SolarImageRecord>();
private long currTime;
private int imgDiff = 0;
public SolarImageDisplay(SolarImageRecord rec, long currTime,
GeneralGridGeometry gridGeometry, boolean logConvert,
DataScale dataScale) throws VizException {
this.record = rec;
this.colorMapParameters = cmp;
int cylindrical, String imageFunction,
TreeMap<Long, SolarImageRecord> functioningRecordMap)
throws VizException {
this.gridGeom = gridGeometry;
this.logConvert = logConvert;
this.dataScale = dataScale;
if (this.logConvert) {
dataCallback = new LogSolarImageDataCallback(record);
imageData = dataCallback.getImageData();
} else {
dataCallback = new SolarImageDataCallback(record);
imageData = dataCallback.getImageData();
}
header = imageData.getHeader();
// if (header == null)
// populateHeader();
nx = imageData.getNx();
ny = imageData.getNy();
headerData = new HeaderData(record);
csConv = new CSConversions(headerData);
this.cylindrical = cylindrical;
this.record = rec;
this.currTime = currTime;
this.imageFunction = imageFunction;
this.functioningRecordMap = functioningRecordMap;
}
@Override
public void paint(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
/*
* remove the following conditon to create a new image on every single
* paint(). This is not efficient. But solves the problem that looping
* on a lot frames, cylindrical image become normal image. Another way
* to solve this problem is to create and use CylindDataCallback and
* LogCylindDataCallback classes.
*/
// if (image == null || projectionChanged || this.getColorMapChanged())
// {
if (image == null || isColorMapChanged) {
if (this.logConvert) {
dataCallback = new LogSolarImageDataCallback(record);
float scaleMin = dataScale.getMinValue().floatValue();
float scaleMax = dataScale.getMaxValue().floatValue();
float range = scaleMax - scaleMin;
float cMapMax = (float) (range / 255.0)
* colorMapParameters.getColorMapMax();
float cMapMin = (float) (range / 255.0)
* colorMapParameters.getColorMapMin();
// System.out.println(" test ****** before colorMapParameters min max = "
// + colorMapParameters.getColorMapMin() + " " +
// colorMapParameters.getColorMapMax() + " cMapMax = " +cMapMax);
if (range <= 255.0) {
if ((colorMapParameters.getColorMapMax() > range)) {
colorMapParameters.setColorMapMax(cMapMax);
}
if ((colorMapParameters.getColorMapMin() > range)) {
colorMapParameters.setColorMapMin(cMapMin);
}
}
else {
if (scaleMin >= 0) {
if (colorMapParameters.getColorMapMax() >= 0
&& cMapMax <= range) {
colorMapParameters.setColorMapMax(cMapMax);
}
if (colorMapParameters.getColorMapMin() >= 0
&& cMapMin <= range) {
colorMapParameters.setColorMapMin(cMapMin);
}
} else {
if (colorMapParameters.getColorMapMax() >= 0
&& cMapMax <= range) {
colorMapParameters.setColorMapMax(cMapMax - scaleMax);
}
if (colorMapParameters.getColorMapMin() >= 0
&& cMapMin <= range) {
colorMapParameters.setColorMapMin(cMapMin - scaleMax);
}
}
}
image = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(dataCallback, colorMapParameters);
} else {
dataCallback = new SolarImageDataCallback(record);
}
if (transform == null || extent == null) {
csConv = new CSConversions(dataCallback.getHeaderData());
if (image != null)
image.dispose();
image = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(dataCallback, this.getColorMapParameters());
// }
if (transform == null) {
try {
transform = new WCSConverter(header);
transform = new WCSConverter(dataCallback.getHeaderData()
.getHeader(), cylindrical);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
@ -204,99 +182,425 @@ public class SolarImageDisplay implements IRenderable {
"Could not create image to world coordinate transform",
e);
}
double[] ll = transform.imageToWorld(new double[] { 0, 0 });
double[] lr = transform.imageToWorld(new double[] { nx, 0 });
double[] ur = transform.imageToWorld(new double[] { nx, ny });
double[] ul = transform.imageToWorld(new double[] { 0, ny });
// double[] ll = transform.imageToWorld(new double[] { -0.5, -0.5
// });
// double[] lr = transform.imageToWorld(new double[] { nx - 0.5,
// -0.5 });
// double[] ur = transform.imageToWorld(new double[] { nx - 0.5, ny
// - 0.5 });
// double[] ul = transform.imageToWorld(new double[] { -0.5, ny -
// 0.5 });
double minX = Math.min(ll[0], ul[0]);
double maxX = Math.max(lr[0], ur[0]);
double minY = Math.min(ll[1], lr[1]);
double maxY = Math.max(ul[1], ur[1]);
if ((maxX - minX) > (maxY - minY)) {
scale = gridGeom.getEnvelope().getSpan(0) / (maxX - minX);
} else {
scale = gridGeom.getEnvelope().getSpan(1) / (maxY - minY);
}
double[] center;
if (paintProps instanceof GraphProperties) {
center = ((GraphProperties) paintProps).getWorldExtent()
.getCenter();
} else {
center = paintProps.getView().getExtent().getCenter();
}
center[0] = gridGeom.getEnvelope().getMedian(0);
center[1] = gridGeom.getEnvelope().getMedian(1);
double[] llp = new double[2];
double[] lrp = new double[2];
double[] ulp = new double[2];
double[] urp = new double[2];
try {
at = AffineTransform.getTranslateInstance(center[0], center[1]);
at.concatenate(AffineTransform.getScaleInstance(scale, -scale));
worldToPixel = new AffineTransform2D(at);
// System.out.println(worldToPixel.toWKT());
pixelToWorld = worldToPixel.inverse();
// System.out.println(pixelToWorld.toWKT());
worldToPixel.transform(ll, 0, llp, 0, 1);
worldToPixel.transform(lr, 0, lrp, 0, 1);
worldToPixel.transform(ul, 0, ulp, 0, 1);
worldToPixel.transform(ur, 0, urp, 0, 1);
} catch (NoninvertibleTransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
throw new VizException(
"Could not create world to pixel coordinate transform",
e);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
throw new VizException(
"Could not create pixel extent for image", e);
}
// handle THEMATIC
if (record.getWavelength().equalsIgnoreCase("THEMATIC")) {
llp = new double[] { 0, 0 };
lrp = new double[] { 1000, 0 };
urp = new double[] { 1000, 1000 };
ulp = new double[] { 0, 1000 };
}
extent = new PixelCoverage(new Coordinate(ulp[0], ulp[1]),
new Coordinate(urp[0], urp[1]), new Coordinate(lrp[0],
lrp[1]), new Coordinate(llp[0], llp[1]));
// System.out.println("**** extent "+ulp[0]+" "+ ulp[1]
// +" "+urp[0]+" "+ urp[1]+" "+ lrp[0]+" "+lrp[1]+" "+
// llp[0]+" "+llp[1] );
}
double[] ll = transform.imageToWorld(new double[] { 0, 0 });
double[] lr = transform.imageToWorld(new double[] {
dataCallback.getImageNx(), 0 });
double[] ur = transform.imageToWorld(new double[] {
dataCallback.getImageNx(), dataCallback.getImageNy() });
double[] ul = transform.imageToWorld(new double[] { 0,
dataCallback.getImageNy() });
/*
* image functioning
*/
String[] elements = ImageFunctionParser.parse(imageFunction);
if (elements != null && elements.length > 1) {
// image differencing
if (elements[0].startsWith("run") || elements[0].startsWith("base")) {
imgDiff = 11;
dataCallback.setImgDiff(imgDiff);
}
// other image function
// else if (...) {
// imgDiff = 12;
// }
dataCallback
.setImageData(getFunctioningImageData(target, elements));
if (image != null)
image.dispose();
image = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(dataCallback,
this.getColorMapParameters());
}
/*
* create new cylindrical image
*/
if (cylindrical != 0) {
image.stage(); // for using in getImageValue
dataCallback.setCylindrical(cylindrical);
// if (projectionChanged || this.getColorMapChanged()) {
dataCallback.setImageData(getCylindImageData());
if (image != null)
image.dispose();
image = target.getExtension(IColormappedImageExtension.class)
.initializeRaster(dataCallback,
this.getColorMapParameters());
// }
if ((transformCylin == null) || (extent == null)) {
try {
transformCylin = new CylindricalConverter();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
throw new VizException(
"Could not create image to world coordinate transform",
e);
}
}
ll = transformCylin.imageToWorld(new double[] { 0, 0 });
lr = transformCylin.imageToWorld(new double[] { 360, 0 });
ur = transformCylin.imageToWorld(new double[] { 360, 180 });
ul = transformCylin.imageToWorld(new double[] { 0, 180 });
}
/*
* for all
*/
double minX = Math.min(ll[0], ul[0]);
double maxX = Math.max(lr[0], ur[0]);
double minY = Math.min(ll[1], lr[1]);
double maxY = Math.max(ul[1], ur[1]);
if ((maxX - minX) > (maxY - minY)) {
scale = gridGeom.getEnvelope().getSpan(0) / (maxX - minX);
} else {
scale = gridGeom.getEnvelope().getSpan(1) / (maxY - minY);
}
double[] center = new double[2];
if (paintProps instanceof GraphProperties) {
center = ((GraphProperties) paintProps).getWorldExtent()
.getCenter();
} else {
center = paintProps.getView().getExtent().getCenter();
}
center[0] = gridGeom.getEnvelope().getMedian(0);
center[1] = gridGeom.getEnvelope().getMedian(1);
double[] llp = new double[2];
double[] lrp = new double[2];
double[] ulp = new double[2];
double[] urp = new double[2];
try {
at = AffineTransform.getTranslateInstance(center[0], center[1]);
at.concatenate(AffineTransform.getScaleInstance(scale, scale));
worldToPixel = new AffineTransform2D(at);
pixelToWorld = worldToPixel.inverse();
worldToPixel.transform(ll, 0, llp, 0, 1);
worldToPixel.transform(lr, 0, lrp, 0, 1);
worldToPixel.transform(ul, 0, ulp, 0, 1);
worldToPixel.transform(ur, 0, urp, 0, 1);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
throw new VizException("Could not create pixel extent for image", e);
}
extent = new PixelCoverage(new Coordinate(ulp[0], ulp[1]),
new Coordinate(urp[0], urp[1]), new Coordinate(lrp[0], lrp[1]),
new Coordinate(llp[0], llp[1]));
image.setContrast(contrast);
image.setBrightness(brightness);
image.setInterpolated(isInterpolated);
target.drawRaster(image, extent, paintProps);
if (dataCallback != null) {
dataCallback.setImageData(null);
}
// projectionChanged = false;
}
public void drawOverlay(IGraphicsTarget target, IDescriptor descriptor,
PaintProperties paintProps, boolean isCarrington)
throws VizException {
try {
if (latLonOverlay == null || recreateLatLonOverlay
|| latLonOverlay.isCarrington() != isCarrington) {
latLonOverlay = new LatLonOverlay(this, descriptor,
latLonInterval, paintProps, isCarrington, cylindrical,
dataCallback.getHeaderData());
latLonOverlay.createLatLines(target);
latLonOverlay.createLonLines(target);
}
latLonOverlay.drawLatLines(target);
latLonOverlay.drawLonLines(target);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
recreateLatLonOverlay = false;
}
public ImageData getCylindImageData() {
double hgln = dataCallback.getHeaderData().getHgln();
double crln = dataCallback.getHeaderData().getCrln();
double L0 = dataCallback.getHeaderData().getL0();
ImageData newImageData = new ImageData();
newImageData.setNx(360);
newImageData.setNy(180);
float[][] newImgArray = new float[newImageData.getNy()][newImageData
.getNx()];
double[] centric = new double[2];
int primeMeridian = 0; // related to the center of the image
if (cylindrical == 2) {
isCarr = true;
} else {
isCarr = false;
}
if (cylindrical == 2) {
if (crln != 0) {
primeMeridian = 180 + (int) crln; // Canvas started from -180
} else {
primeMeridian = 180 + (int) (L0 + hgln);
}
if (primeMeridian < 360) {
primeMeridian = primeMeridian + 360;
}
if (primeMeridian > 360) {
primeMeridian = primeMeridian - 360;
}
} else if (cylindrical == 1) {
primeMeridian = 180 + (int) hgln; // Canvas started from -180
}
WCSConverter transformAlt = null;
try {
transformAlt = new WCSConverter(dataCallback.getHeaderData()
.getHeader(), cylindrical);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
for (int i = 0; i < newImageData.getNy(); i++) {
for (int j = 0; j < newImageData.getNx(); j++) {
if (((j >= (primeMeridian - 90)) && (j <= (primeMeridian + 90)))
|| (((primeMeridian + 90) > 360) && (j >= 0) && (j < ((primeMeridian + 90) - 360)))
|| (((primeMeridian - 90) < 0) && (j <= 360) && (j > ((primeMeridian - 90) + 360)))) {
double[] latlon = new double[] { j - 180, i - 90 };
centric = csConv.heliographicToHeliocentric(latlon, isCarr);
double img[] = transformAlt.WorldToImage(centric);
double val = getImageValue((int) (Math.round(img[0])),
(int) (Math.round(img[1])), image);
double imgVal = logConvert ? new Double(Math.pow(10.0,
formatValue(val))) : val;
newImgArray[i][j] = (float) (imgVal);
}
else if (dataCallback.getHeaderData().isSdoHmi()) {
// hmi default is not 0
newImgArray[i][j] = (-1500);
}
}
}
int n = 0;
float[] imgDataRec = new float[newImageData.getNy()
* newImageData.getNx()];
// for (int j = 180 - 1; j >= 0; j--) { // Reverse order of rows
for (int i = 0; i < newImageData.getNy(); i++) {
for (int j = 0; j < newImageData.getNx(); j++) {
imgDataRec[n++] = newImgArray[i][j];
}
}
newImageData.setImageValues(imgDataRec);
return newImageData;
}
/*
* get new imageData and directly set to the dataCallback
*/
public ImageData getFunctioningImageData(IGraphicsTarget target,
String[] elements) throws VizException {
// the following objects are declared as lists for general
ImageData functioningImageData = null;
List<SolarImageDataCallback> functioningCallback = new ArrayList<SolarImageDataCallback>();
List<SolarImageRecord> functioningRecords = new ArrayList<SolarImageRecord>();
Iterator iterator = functioningRecordMap.entrySet().iterator();
while (iterator.hasNext()) {
@SuppressWarnings("unchecked")
Map.Entry<Long, SolarImageRecord> entry = (Map.Entry<Long, SolarImageRecord>) iterator
.next();
long time = (Long) entry.getKey();
if (elements[0].startsWith("run") || elements[0].startsWith("base")) {
if (time == currTime) {
functioningRecords.add((SolarImageRecord) entry.getValue());
break;
}
} else {
functioningRecords.add((SolarImageRecord) entry.getValue());
}
}
if (functioningRecords.size() > 0) {
for (int i = 0; i < functioningRecords.size(); i++) {
if (this.logConvert) {
functioningCallback.add(new LogSolarImageDataCallback(
functioningRecords.get(i)));
} else {
functioningCallback.add(new SolarImageDataCallback(
functioningRecords.get(i)));
}
}
} else {
return dataCallback.getImageData();
}
if (functioningCallback.size() > 0) {
if (elements[0].startsWith("run") || elements[0].startsWith("base")) {
// functioningCallback size = 1
if (dataCallback.getImageNx() == functioningCallback.get(0)
.getImageNx()
&& dataCallback.getImageNy() == functioningCallback
.get(0).getImageNy()) {
functioningImageData = dataCallback.getImageData();
functioningImageData
.setImageValues(imgDifference(functioningCallback
.get(0)));
}
}
}
for (int i = 0; i < functioningCallback.size(); i++) {
if (functioningCallback.get(i) != null) {
functioningCallback.get(i).setImageData(null);
functioningCallback.remove(i);
}
}
return functioningImageData;
}
public float[] imgDifference(SolarImageDataCallback callback)
throws VizException {
int currImageDataSize = dataCallback.getImageNx()
* dataCallback.getImageNy();
float[] imgDataRec = new float[currImageDataSize];
ImageData currImageData = dataCallback.getImageData();
if (currImageData == null) { // now not happen
if (this.logConvert) {
dataCallback = new LogSolarImageDataCallback(record);
currImageData = dataCallback.getImageData();
} else {
dataCallback = new SolarImageDataCallback(record);
currImageData = dataCallback.getImageData();
}
}
ImageData functioningImageData = callback.getImageData();
String[] elements = ImageFunctionParser.parse(imageFunction);
WCSConverter funcTransform = null;
try {
funcTransform = new WCSConverter(callback.getHeaderData()
.getHeader(), cylindrical);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
int n = 0;
if (!transform.hasEqualNavigation()) {
for (int i = 0; i < currImageData.getNy(); i++) {
for (int j = 0; j < currImageData.getNx(); j++) {
double[] world = transform
.imageToWorld(new double[] { i, j });
double[] img2 = funcTransform.WorldToImage(world);
int ii = (int) Math.round(img2[0]);
int jj = (int) Math.round(img2[1]);
if (ii < 0 || jj < 0 || ii >= currImageData.getNy()
|| jj >= currImageData.getNx()) {
imgDataRec[n] = Float.NaN;
} else {
imgDataRec[n] = getImgDataRec(elements[0],
currImageData.getImageValues()[j + i
* currImageData.getNx()],
functioningImageData.getImageValues()[jj + ii
* currImageData.getNx()]);
}
n++;
}
}
} else {
for (int i = 0; i < currImageDataSize; i++) {
imgDataRec[n] = getImgDataRec(elements[0],
currImageData.getImageValues()[i],
functioningImageData.getImageValues()[i]);
n++;
}
}
return imgDataRec;
}
public float getImgDataRec(String element, float val1, float val2) {
float dataRec = 0.0f;
if (element.contains("Ratio")) {
dataRec = val1 / val2;
} else if (element.contains("Diff")) {
dataRec = val1 - val2;
}
return dataRec;
}
public void dispose() {
if (this.image != null)
this.image.dispose();
if (latLonOverlay != null) {
latLonOverlay.dispose();
}
}
public Map<String, Object> interrogate(ReferencedCoordinate coord)
@ -310,42 +614,59 @@ public class SolarImageDisplay implements IRenderable {
double[] world = new double[2];
pixelToWorld.transform(pixel, 0, world, 0, 1);
map.put("HCC", new Coordinate(formatValue(world[0]),
formatValue(world[1])));// move down
double image[] = transform.WorldToImage(world);
// remember that image was flipped during earlier and stored with
// first pixel as top left
image[1] = ny - 1 - image[1];
map.put("Image", new Coordinate(formatValue(image[0]),
formatValue(image[1])));
double img[] = transform.WorldToImageSamp(world);
double[] locWorld = (new CSConversions(headerData))
.heliocentricToHeliographic(world, false);
if (locWorld[0] > 180)
locWorld[0] = locWorld[0] - 360;
else if (locWorld[0] < -180)
locWorld[0] = locWorld[0] + 360;
map.put("StonyHurst", new Coordinate(formatValue(locWorld[0]),
formatValue(locWorld[1])));
if (cylindrical != 0) {
img = transformCylin.WorldToImage(world);
}
map.put("Image", new Coordinate(formatValue(img[0]),
formatValue(img[1])));
locWorld = (new CSConversions(headerData))
.heliocentricToHeliographic(world, true);
if (locWorld[0] > 360)
locWorld[0] = locWorld[0] - 360;
else if (locWorld[0] < -360)
locWorld[0] = locWorld[0] + 360;
map.put("Carrington", new Coordinate(formatValue(locWorld[0]),
formatValue(locWorld[1])));
if (cylindrical == 1) {
map.put("StonyHurst", new Coordinate(formatValue(world[0]),
formatValue(world[1])));
} else if (cylindrical == 2) {
map.put("Carrington", new Coordinate(formatValue(world[0]),
formatValue(world[1])));
} else {
double[] locWorld = csConv.heliocentricToHeliographic(world,
false);
long x = Math.round(image[0]);
long y = Math.round(image[1]);
double val = getImageValue((int) x, (int) y);
if (locWorld[0] >= 180)
locWorld[0] = locWorld[0] - 360;
else if (locWorld[0] <= -180)
locWorld[0] = locWorld[0] + 360;
map.put("StonyHurst", new Coordinate(formatValue(locWorld[0]),
formatValue(locWorld[1])));
locWorld = csConv.heliocentricToHeliographic(world, true);
if (locWorld[0] >= 180)
locWorld[0] = locWorld[0] - 360;
else if (locWorld[0] <= -180)
locWorld[0] = locWorld[0] + 360;
map.put("Carrington", new Coordinate(formatValue(locWorld[0]),
formatValue(locWorld[1])));
}
double val = getImageValue((int) Math.round(img[0]),
(int) Math.round(img[1]), image);
map.put("Display Value", new Double(formatValue(val)));
map.put("Data Value",
new Double(formatValue(dataCallback.getOriginalValue(val))));
// remove cylindrical invalid area map
if (cylindrical != 0 && val == Double.POSITIVE_INFINITY
|| val == Double.NEGATIVE_INFINITY) {
return null;
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
@ -368,19 +689,21 @@ public class SolarImageDisplay implements IRenderable {
return newVal;
}
public double getImageValue(int x, int y) {
public double getImageValue(int x, int y, IImage image) {
double value = Float.NaN;
if (isInImageRange(x, y)) {
if (image instanceof IColormappedImage) {
value = ((IColormappedImage) image).getValue(x, y);
}
}
return value;
}
private boolean isInImageRange(int x, int y) {
return (x >= 0) && (x < nx) && (y >= 0) && (y < ny);
return (x >= 0) && (x < dataCallback.getImageNx()) && (y >= 0)
&& (y < dataCallback.getImageNy());
}
public void setBrightness(float brightness) {
@ -395,14 +718,20 @@ public class SolarImageDisplay implements IRenderable {
this.isInterpolated = isInterpolated;
}
public ColorMapParameters getColorMapParameters() {
return colorMapParameters;
}
public void setColorMapParameters(ColorMapParameters params) {
this.colorMapParameters = params;
this.isColorMapChanged = true;
}
public boolean getColorMapChanged() {
return isColorMapChanged;
}
public void setColorMapChanged(boolean val) {
this.isColorMapChanged = val;
;
}
public PixelCoverage getPixelCoverage() {
@ -413,12 +742,98 @@ public class SolarImageDisplay implements IRenderable {
return worldToPixel;
}
public MathTransform getPixelToWorld() {
return pixelToWorld;
}
public CSConversions getCSConversions() {
return csConv;
}
public HeaderData getHeaderData() {
return headerData;
public int getCylindrical() {
return cylindrical;
}
public void setCylindrical(int cylindrical) {
if (this.cylindrical != cylindrical) {
this.cylindrical = cylindrical;
recreateLatLonOverlay = true;
// projectionChanged = true;
}
}
public int getLatLonInterval() {
return latLonInterval;
}
public void setLatLonInterval(int latLonInterval) {
if (this.latLonInterval != latLonInterval) {
this.latLonInterval = latLonInterval;
recreateLatLonOverlay = true;
}
}
public SolarImageRecord getImageRecord() {
return record;
}
public void setImageRecord(SolarImageRecord record) {
this.record = record;
}
public Coordinate getPixelCoordFromLatLon(Coordinate latlonCoord) {
Coordinate pixelCoord = null;
try {
double[] pixel = new double[2];
if (cylindrical == 0) {
double[] latlon = { latlonCoord.x, latlonCoord.y };
double[] centric = csConv.heliographicToHeliocentric(latlon,
false);
worldToPixel.transform(centric, 0, pixel, 0, 1);
pixelCoord = new Coordinate(pixel[0], pixel[1]);
} else {
double x = (latlonCoord.x > 180) ? (latlonCoord.x - 360.0)
: latlonCoord.x;
double[] latlon = { x, latlonCoord.y };
worldToPixel.transform(latlon, 0, pixel, 0, 1);
pixelCoord = new Coordinate(pixel[0], pixel[1]);
}
} catch (Exception e) {
return null;
}
return pixelCoord;
}
public Coordinate getLatLonFromPixel(Coordinate pixelCoord) {
Coordinate latlonCoord = null;
try {
double[] pixel = { pixelCoord.x, pixelCoord.y };
double[] world = new double[2];
pixelToWorld.transform(pixel, 0, world, 0, 1);
if (cylindrical == 0) {
double[] latlon = csConv.heliocentricToHeliographic(world,
false);
// if (latlon[0] >= 180)
// latlon[0] = latlon[0] - 360;
// else if (latlon[0] <= -180)
// latlon[0] = latlon[0] + 360;
latlonCoord = new Coordinate(latlon[0], latlon[1]);
} else {
latlonCoord = new Coordinate(world[0], world[1]);
}
} catch (Exception e) {
return null;
}
return latlonCoord;
}
}

View file

@ -19,11 +19,17 @@
**/
package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import org.eclipse.swt.widgets.Event;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.input.InputAdapter;
import com.vividsolutions.jts.geom.Coordinate;
@ -37,6 +43,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 05, 2012 958 sgurung Initial creation
* 12/16/13 #958 sgurung Set virtual cursor to point to lat/lon instead of pixel coordinates (in multipnaes)
*
*
* </pre>
*
@ -48,7 +56,7 @@ public class SolarImageInputAdapter<T extends SolarImageResource> extends
InputAdapter {
private T resource;
public SolarImageInputAdapter(T resource) {
this.resource = resource;
}
@ -57,14 +65,76 @@ public class SolarImageInputAdapter<T extends SolarImageResource> extends
public boolean handleMouseMove(int x, int y) {
IDisplayPaneContainer container = resource.getResourceContainer();
Coordinate c = container.translateClick(x, y);
if (c != null) {
resource.sampleCoord = new ReferencedCoordinate(c);
} else {
resource.sampleCoord = null;
boolean isActiveResource = false;
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
IDisplayPane activePane = editor.getActiveDisplayPane();
ResourceList acResources = activePane.getDescriptor().getResourceList();
int acRscSize = acResources.size();
for (int i = acRscSize - 1; i >= 0; i--) {
ResourcePair rp = acResources.get(i);
AbstractVizResource<?, ?> activeRsc = rp.getResource();
if (activeRsc != null
&& activeRsc instanceof SolarImageResource
&& rp.getProperties().isVisible()
&& !((SolarImageResource) activeRsc).getLegendStr().equals(
"No Data")) {
if (activeRsc.equals(resource)) {
isActiveResource = true;
}
break;
}
}
if (resource.getResourceContainer().getDisplayPanes().length > 1) {
Coordinate latLonCoord = ((SolarImageResource) resource)
.getLatLonFromPixel(c);
for (IDisplayPane pane : resource.getResourceContainer()
.getDisplayPanes()) {
if (!pane.equals(activePane) && isActiveResource) {
ResourceList resources = pane.getDescriptor()
.getResourceList();
int size = resources.size();
for (int i = 0; i < size && size > 1; i++) {
ResourcePair rp = resources.get(i);
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc != null && rsc instanceof SolarImageResource
&& rp.getProperties().isVisible()) {
((SolarImageResource) rsc)
.setVirtualCursor(latLonCoord);
((SolarImageResource) rsc).issueRefresh();
}
}
}
}
}
if (isActiveResource) {
if (c != null) {
resource.sampleCoord = new ReferencedCoordinate(c);
} else {
resource.sampleCoord = null;
}
}
if (resource.isSampling()) {
resource.issueRefresh();
}
return false;
}
@ -75,6 +145,7 @@ public class SolarImageInputAdapter<T extends SolarImageResource> extends
public boolean handleMouseExit(Event event) {
resource.sampleCoord = null;
resource.virtualCursor = null;
if (resource.isSampling()) {
resource.issueRefresh();
}

View file

@ -12,14 +12,21 @@ import gov.noaa.nws.ncep.viz.rsc.solarimage.actions.CarrLatLonCapability;
import gov.noaa.nws.ncep.viz.rsc.solarimage.actions.CylindricalCedCapability;
import gov.noaa.nws.ncep.viz.rsc.solarimage.actions.StonyLatLonCapability;
import gov.noaa.nws.ncep.viz.rsc.solarimage.display.SolarImageMatchCriteria;
import gov.noaa.nws.ncep.viz.rsc.solarimage.util.ImageFunctionParser;
import gov.noaa.nws.ncep.viz.ui.display.ColorBarFromColormap;
import gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
import org.eclipse.swt.graphics.RGB;
import org.opengis.referencing.FactoryException;
@ -76,7 +83,12 @@ import com.vividsolutions.jts.geom.Coordinate;
* NCNonMapDescriptor
* 03/19/2013 958 qzhou, sgurung implemented colormap and colorbar
* 04/03/2013 958 qzhou Added cylindrical display to updateFrameData, paintFrame,
* inspect, dispose and construct.
* inspect, dispose and construct.
* 11/04/2013 958 qzhou Combined CylindricalDisplay with SolarImageDisplay
* 11/12/2013 958 qzhou Add latlonOverlay dispose
* 11/27/2013 958 sgurung Add method setAllFramesColorMapChanged()
* 12/16/2013 #958 sgurung Set virtual cursor to point to lat/lon instead of pixel coordinates (in multipnaes)
* 12/27/2013 #1046 qzhou Added getFunctioningRecords method
* Sep 5,2013 2051 mnash Fixed a deprecated method.
* </pre>
*
@ -101,7 +113,9 @@ public class SolarImageResource extends
private DataScale scale = null;
SolarImageDisplay imageDisplay;
protected IRscDataObject rscDataObj;
protected int interval;
// sampling
boolean sampling = false;
@ -112,6 +126,16 @@ public class SolarImageResource extends
protected ReferencedCoordinate sampleCoord;
private boolean isColorMapChanged;
protected Coordinate virtualCursor;// virtual cursor location
protected TreeMap<Long, SolarImageRecord> functioningRecordMap = new TreeMap<Long, SolarImageRecord>();
private RGB rgbW;
private RGB rgbB;
protected static class SampleResult {
public SampleResult() {
@ -122,31 +146,28 @@ public class SolarImageResource extends
public RGB[] colors;
}
// latlon overlay
public boolean isCarrington = false;
protected boolean displayLatLonOverlay = false;
private LatLonOverlay latLonOverlay;
private LatLonCylindOverlay latLonCylindOverlay;
// Cylindric projection
// Cylindrical projection
private int cylindrical = 0; // 0--no cylindrical, 1--stony, 2--carrington
private CylindCedDisplay cylindCedDisplay;
// image differencing
private int difference = 1; // 0--no compare, 1--rundiff+frame,
// 2--runratio+frame,
// 3--rundiff+time, 4--runratio+time,
// 5----runbase+frame, 6--runbase+time,
private int latLonInterval = 0;
private String imageFunction;
protected class FrameData extends AbstractFrameData {
// save only the image which best time matches to this frame.
// if this is the dominant resource then this will be an exact match
// since this record's time was used to generate the timeline.
//
private SolarImageDisplay imageDisplay = null;
private CylindCedDisplay cylindCedDisplay = null;
private SolarImageDisplay imageDisplay = null;
private long timeMatch = -1;
@ -158,6 +179,7 @@ public class SolarImageResource extends
protected FrameData(DataTime time, int interval) {
super(time, interval);
dateFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
}
// use the dfltRecordRscDataObj which just stores the one
@ -176,61 +198,50 @@ public class SolarImageResource extends
SolarImageRecord imgRec = (SolarImageRecord) pdo;
long newTimeMatch = timeMatch(pdo.getDataTime());
long currTime = 0;
if (newTimeMatch < 0) { // sanity check.
return false;
}
/* Add CylindCedDisplay with imageDisplay */
if (imageDisplay == null) {
try {
// setColorMapParametersAndColorBar();
imageDisplay = new SolarImageDisplay(imgRec,
colorMapParams, descriptor.getGridGeometry(),
log10scale, scale);
currTime = pdo.getDataTime().getValidTime().getTime()
.getTime();
imageDisplay = new SolarImageDisplay(imgRec, currTime,
descriptor.getGridGeometry(), log10scale,
cylindrical, imageFunction, functioningRecordMap);
setLegendForFrame(imgRec);
} catch (VizException e) {
System.out.println("Error creating SolarImageDisplay:"
+ e.getMessage());
statusHandler.handle(
Priority.PROBLEM,
"Error creating SolarImageDisplay"
+ e.getLocalizedMessage(), e);
return false;
} catch (Exception e) {
statusHandler.handle(
Priority.PROBLEM,
"Error creating SolarImageDisplay"
+ e.getLocalizedMessage(), e);
return false;
}
timeMatch = newTimeMatch;
if ((imageDisplay != null) && (cylindCedDisplay != null)) {
if (imageDisplay != null) {
return true;
}
}
if (cylindCedDisplay == null) {
try {
// setColorMapParametersAndColorBar();
cylindCedDisplay = new CylindCedDisplay(imgRec,
colorMapParams, descriptor.getGridGeometry(),
log10scale, scale, cylindrical, latLonInterval);
setLegendForFrame(imgRec);
} catch (VizException e) {
System.out.println("Error creating cylindCedDisplay:"
+ e.getMessage());
// return false;
}
timeMatch = newTimeMatch;
if ((imageDisplay != null) && (cylindCedDisplay != null)) {
return true;
}
}
// determine if this image is a better time match than the current
// one.
// determine if this image is a better time match than current one
if (newTimeMatch < timeMatch) {
imageDisplay.dispose();
try {
// setColorMapParametersAndColorBar();
imageDisplay = new SolarImageDisplay(imgRec,
colorMapParams, descriptor.getGridGeometry(),
log10scale, scale);
currTime = pdo.getDataTime().getValidTime().getTime()
.getTime();
imageDisplay = new SolarImageDisplay(imgRec, currTime,
descriptor.getGridGeometry(), log10scale,
cylindrical, imageFunction, functioningRecordMap);
setLegendForFrame(imgRec);
} catch (VizException e) {
System.out.println("Error creating SolarImageDisplay:"
@ -238,61 +249,10 @@ public class SolarImageResource extends
return false;
}
// timeMatch = newTimeMatch;
cylindCedDisplay.dispose();
try {
// setColorMapParametersAndColorBar();
cylindCedDisplay = new CylindCedDisplay(imgRec,
colorMapParams, descriptor.getGridGeometry(),
log10scale, scale, cylindrical, latLonInterval);
setLegendForFrame(imgRec);
} catch (VizException e) {
System.out.println("Error creating cylindCedDisplay:"
+ e.getMessage());
return false;
}
timeMatch = newTimeMatch;
return true;
}
// if( imageDisplay == null ) {
// try {
// //setColorMapParametersAndColorBar();
// imageDisplay = new SolarImageDisplay( imgRec, colorMapParams,
// descriptor.getGridGeometry(), log10scale, scale);
// setLegendForFrame( imgRec );
//
// } catch (VizException e) {
// System.out.println("Error creating SolarImageDisplay:"+e.getMessage()
// );
// return false;
// }
//
// timeMatch = newTimeMatch;
// return true;
// }
// determine if this image is a better time match than the current
// one.
// if( newTimeMatch < timeMatch ) {
// imageDisplay.dispose();
// try {
// //setColorMapParametersAndColorBar();
// imageDisplay = new SolarImageDisplay( imgRec, colorMapParams,
// descriptor.getGridGeometry(), log10scale, scale, cylindrical);
// setLegendForFrame( imgRec );
// } catch (VizException e) {
// System.out.println("Error creating SolarImageDisplay:"+e.getMessage()
// );
// return false;
// }
//
// timeMatch = newTimeMatch;
// return true;
// }
imgRec.setRawData(null);
return false;
}
@ -301,7 +261,6 @@ public class SolarImageResource extends
}
// TODO : probably not correct : fix this as it needs to be.
//
public void setLegendForFrame(SolarImageRecord rec) {
String timeStr = dateFmt.format(rec.getDataTime().getRefTime());
@ -337,12 +296,10 @@ public class SolarImageResource extends
@Override
public void dispose() {
if (imageDisplay != null) {
imageDisplay.dispose();
}
if (cylindCedDisplay != null) {
cylindCedDisplay.dispose();
}
super.dispose();
}
}
@ -353,6 +310,8 @@ public class SolarImageResource extends
solarImgRscData = resourceData;
resourceData.addChangeListener(this);
samplingRsc = new Sampling();
this.rgbW = new RGB(255, 255, 255);
this.rgbB = new RGB(0, 0, 0);
getCapabilities().addCapability(CarrLatLonCapability.class);
getCapabilities().addCapability(StonyLatLonCapability.class);
@ -361,23 +320,30 @@ public class SolarImageResource extends
getCapability(ColorMapCapability.class).setSuppressingMenuItems(true);
getCapability(ImagingCapability.class).setSuppressingMenuItems(true);
getCapability(ColorableCapability.class).setSuppressingMenuItems(true);
imageFunction = solarImgRscData.getImageFunction();
}
@Override
protected void disposeInternal() {
IDisplayPaneContainer container = getResourceContainer();
if (container != null) {
container.unregisterMouseHandler(inputAdapter);
}
// don't we want to remove this as a change listener?
getDescriptor().getResourceList().remove(cbarRscPair);
if (cbarResource.getResourceData().getColorbar() != null) {
if (cbarResource != null
&& cbarResource.getResourceData().getColorbar() != null) {
cbarResource.getResourceData().getColorbar().dispose();
cbarResource.getResourceData().setColorBar(null);
}
if (samplingRsc != null) {
samplingRsc.dispose();
}
super.disposeInternal();
}
@ -392,121 +358,106 @@ public class SolarImageResource extends
// could always just save the record when the frame is updated and
// create/save the imageDisplay when on the first paint of this frame.
if (cylindrical != 0) {
cylindCedDisplay = currFrame.cylindCedDisplay;
cylindCedDisplay.setCylindrical(cylindrical);
if (cylindCedDisplay != null) {
if (hasCapability(ImagingCapability.class)) {
ImagingCapability imaging = getCapability(ImagingCapability.class);
cylindCedDisplay.setBrightness(imaging.getBrightness());
cylindCedDisplay.setContrast(imaging.getContrast());
cylindCedDisplay.setInterpolationState(imaging
.isInterpolationState());
}
if (hasCapability(ColorMapCapability.class)) {
ColorMapCapability cMap = getCapability(ColorMapCapability.class);
cylindCedDisplay.setColorMapParameters(cMap
.getColorMapParameters());
}
cylindCedDisplay.paint(target, paintProps);
if (isSampling()) {
samplingRsc.paintResult(target, descriptor, paintProps,
sampleCoord);
}
// TODO : draw the lat lon lines even if there is no image?
if (isLatLonOverlayOn()) {
// int latLonInterval = 0;
try {
if (isCarrington) {
latLonInterval = Integer.parseInt(getCapabilities()
.getCapability(resourceData,
CarrLatLonCapability.class)
.getInterval());
} else {
latLonInterval = Integer.parseInt(getCapabilities()
.getCapability(resourceData,
StonyLatLonCapability.class)
.getInterval());
}
} catch (NumberFormatException e) {
}
latLonCylindOverlay = new LatLonCylindOverlay(
cylindCedDisplay, descriptor, latLonInterval,
paintProps);
try {
latLonCylindOverlay.drawLatLines(target);
latLonCylindOverlay.drawLonLines(target);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
SolarImageDisplay imageDisplay = currFrame.imageDisplay;
if (imageDisplay != null) {
if (hasCapability(ImagingCapability.class)) {
ImagingCapability imaging = getCapability(ImagingCapability.class);
imageDisplay.setBrightness(imaging.getBrightness());
imageDisplay.setContrast(imaging.getContrast());
imageDisplay.setInterpolationState(imaging
.isInterpolationState());
}
} else {
imageDisplay = currFrame.imageDisplay;
if (imageDisplay != null) {
if (hasCapability(ColorMapCapability.class)) {
ColorMapCapability cMap = getCapability(ColorMapCapability.class);
colorMapParams = cMap.getColorMapParameters();
}
if (hasCapability(ImagingCapability.class)) {
ImagingCapability imaging = getCapability(ImagingCapability.class);
imageDisplay.setBrightness(imaging.getBrightness());
imageDisplay.setContrast(imaging.getContrast());
imageDisplay.setInterpolationState(imaging
.isInterpolationState());
}
if (isColorMapChanged) {
updateColorMap();
imageDisplay.setColorMapChanged(isColorMapChanged);
}
if (hasCapability(ColorMapCapability.class)) {
ColorMapCapability cMap = getCapability(ColorMapCapability.class);
imageDisplay.setColorMapParameters(cMap
.getColorMapParameters());
}
imageDisplay.setCylindrical(cylindrical);
imageDisplay.setColorMapParameters(colorMapParams);
imageDisplay.paint(target, paintProps);
imageDisplay.paint(target, paintProps);
if (isSampling()) {
samplingRsc.paintResult(target, descriptor, paintProps,
sampleCoord);
}
isColorMapChanged = false;
// TODO : draw the lat lon lines even if there is no image?
if (isLatLonOverlayOn()) {
try {
if (isCarrington) {
latLonInterval = Integer.parseInt(getCapabilities()
.getCapability(resourceData,
CarrLatLonCapability.class)
.getInterval());
} else {
latLonInterval = Integer.parseInt(getCapabilities()
.getCapability(resourceData,
StonyLatLonCapability.class)
.getInterval());
}
} catch (NumberFormatException e) {
// draw the VirtualCursor and sampling
drawVirtualCursor(paintProps, target);
if (isSampling()) {
samplingRsc.paintResult(target, descriptor, paintProps,
sampleCoord);
}
// TODO : draw the lat lon lines even if there is no image?
if (isLatLonOverlayOn()) {
try {
if (isCarrington) {
imageDisplay.setLatLonInterval(Integer
.parseInt(getCapabilities().getCapability(
resourceData,
CarrLatLonCapability.class)
.getInterval()));
} else {
imageDisplay.setLatLonInterval(Integer
.parseInt(getCapabilities().getCapability(
resourceData,
StonyLatLonCapability.class)
.getInterval()));
}
} catch (NumberFormatException e) {
latLonOverlay = new LatLonOverlay(imageDisplay, descriptor,
latLonInterval, paintProps, isCarrington);
}
imageDisplay.drawOverlay(target, descriptor, paintProps,
isCarrington);
try {
latLonOverlay.drawLatLines(target);
latLonOverlay.drawLonLines(target);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
}
private void updateColorMap() {
float scaleMin = scale.getMinValue().floatValue();
float scaleMax = scale.getMaxValue().floatValue();
float range = scaleMax - scaleMin;
float cMapMax = (float) (range / 255.0)
* colorMapParams.getColorMapMax();
float cMapMin = (float) (range / 255.0)
* colorMapParams.getColorMapMin();
if (range <= 255.0) {
if ((colorMapParams.getColorMapMax() > range)) {
colorMapParams.setColorMapMax(cMapMax);
}
if ((colorMapParams.getColorMapMin() > range)) {
colorMapParams.setColorMapMin(cMapMin);
}
}
else {
if (scaleMin >= 0) {
if ((colorMapParams.getColorMapMax() >= 0)
&& (cMapMax <= range)) {
colorMapParams.setColorMapMax(cMapMax);
}
if ((colorMapParams.getColorMapMin() >= 0)
&& (cMapMin <= range)) {
colorMapParams.setColorMapMin(cMapMin);
}
} else {
if ((colorMapParams.getColorMapMax() >= 0)
&& (cMapMax <= range)) {
colorMapParams.setColorMapMax(cMapMax - scaleMax);
}
if ((colorMapParams.getColorMapMin() >= 0)
&& (cMapMin <= range)) {
colorMapParams.setColorMapMin(cMapMin - scaleMax);
}
}
}
@ -528,6 +479,14 @@ public class SolarImageResource extends
this.cylindrical = cylind;
}
public int getDifference() {
return difference;
}
public void setDifference(int difference) {
this.difference = difference;
}
@Override
public void initResource(IGraphicsTarget target) throws VizException {
@ -543,7 +502,9 @@ public class SolarImageResource extends
cbarResource = (ColorBarResource) cbarRscPair.getResource();
setColorMapParametersAndColorBar();
if (cbarResource != null) {
setColorMapParametersAndColorBar();
}
if (descriptor.getRenderableDisplay().getContainer().getDisplayPanes().length > 1) {
descriptor.getTimeMatcher().redoTimeMatching(descriptor);
@ -556,9 +517,125 @@ public class SolarImageResource extends
}
// use the default which just gets all the images in the db regardless
// of
// the number of frames selected.
// of the number of frames selected.
queryRecords();
getFunctioningRecords();
}
public Map getFunctioningRecords() {
/*
* A imageFunction includes function name and parameters. The
* imageDifferencing is one of imageFunctions. The first parameter in
* imagedifferencing is time. For runDiffTime, the time is minutes; for
* basediffTime, the time is a date with yyMMdd/hhmm format.
*/
String[] elements = ImageFunctionParser.parse(imageFunction);
long funcTimeDiff = 0;
if (elements != null && elements[0].startsWith("run")) {// runDiffTime
if (elements[1] != null) {
funcTimeDiff = Integer.parseInt(elements[1]) * 60 * 1000;
}
}
else if (elements != null && elements[0].startsWith("base")) { // baseDiff
if (elements[1] != null) { // 131127/1300
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd/HHmm");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
Date date = sdf.parse(elements[1]);
funcTimeDiff = date.getTime();
} catch (ParseException e) {
statusHandler.handle(Priority.PROBLEM,
"Error parsing date. Use yyMMdd/HHmm format for the date."
+ e.getLocalizedMessage(), e);
}
}
}
// frameDataMap to frameDataTimeList
List<Calendar> frameDataTimeList = new ArrayList<Calendar>();
Iterator iterator = frameDataMap.entrySet().iterator();
while (iterator.hasNext()) {
@SuppressWarnings("unchecked")
Map.Entry<Long, AbstractFrameData> entry = (Map.Entry<Long, AbstractFrameData>) iterator
.next();
AbstractFrameData obj = (AbstractFrameData) entry.getValue();
DataTime time = obj.getFrameTime();
frameDataTimeList.add((Calendar) time.getRefTimeAsCalendar());
}
// construct functioningRecordMap
SolarImageRecord record = null;
long functioningRecordTime = 0;
if (elements != null && elements[0].startsWith("base")) {
functioningRecordTime = funcTimeDiff;
for (IRscDataObject obj : newRscDataObjsQueue) {
Calendar calendar = obj.getDataTime().getValidTime();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
long timeOnQueue = calendar.getTimeInMillis();// trunk time
if (timeOnQueue == functioningRecordTime) {
DfltRecordRscDataObj DfltObj = (DfltRecordRscDataObj) obj;
record = (SolarImageRecord) DfltObj.getPDO();
break;
}
}
if (record != null) {
for (int i = 0; i < frameDataTimeList.size(); i++)
functioningRecordMap.put(frameDataTimeList.get(i)
.getTimeInMillis(), record);// orig time
}
}
else {
for (int i = 0; i < frameDataTimeList.size(); i++) {
Calendar cal = frameDataTimeList.get(i);
Calendar calen = (Calendar) cal.clone();
calen.set(Calendar.SECOND, 0);
calen.set(Calendar.MILLISECOND, 0);
functioningRecordTime = calen.getTimeInMillis() - funcTimeDiff;
for (IRscDataObject obj : newRscDataObjsQueue) {
Calendar calendar = obj.getDataTime().getValidTime();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
long timeOnQueue = calendar.getTimeInMillis();
if (timeOnQueue == functioningRecordTime) {
// System.out.println("***n " + obj.getDataTime() + " "
// + frameDataTimeList.get(i).getTime());
DfltRecordRscDataObj DfltObj = (DfltRecordRscDataObj) obj;
record = (SolarImageRecord) DfltObj.getPDO();
// put frameDataMap time here
functioningRecordMap.put(frameDataTimeList.get(i)
.getTimeInMillis(), record);
break;
}
}
}
}
// System.out.println("*** " + functioningRecordMap.size() + " "
// + frameDataTimeList.size());
return functioningRecordMap;
}
public String getLegendStr() {
@ -576,14 +653,12 @@ public class SolarImageResource extends
*/
@Override
public String inspect(ReferencedCoordinate coord) throws VizException {
if (coord == null) {
return "No Data";
}
if (!sampling) {
return "";
}
StringBuilder sb = new StringBuilder();
if (coord == null)
return "No Data";
if (!sampling)
return "";
if (cylindrical != 0) {
if (cylindrical == 1) {
@ -593,83 +668,57 @@ public class SolarImageResource extends
}
try {
FrameData currFrame = (FrameData) getCurrentFrame();
cylindCedDisplay = currFrame.cylindCedDisplay;
if (cylindCedDisplay == null) {
if (coord.asLatLon().y > 750.0 || coord.asLatLon().y < 250.0) {
return "";
}
sb.append("Pixel: ");
double[] coordDbl = new double[2];
coordDbl[0] = cylindCedDisplay.formatValue(coord.asLatLon().x);
coordDbl[1] = cylindCedDisplay.formatValue(coord.asLatLon().y);
// sb.append(coord.asLatLon().toString());
sb.append((new Coordinate(coordDbl[0], coordDbl[1])).toString());
sb.append('\n');
Map<String, Object> map = cylindCedDisplay.interrogate(coord);
for (Map.Entry<String, Object> item : map.entrySet()) {
sb.append(item.getKey() + ": ");
sb.append(item.getValue().toString());
sb.append('\n');
}
return sb.toString();
} catch (TransformException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (FactoryException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
} else {
try {
FrameData currFrame = (FrameData) getCurrentFrame();
imageDisplay = currFrame.imageDisplay;
if (imageDisplay == null) {
return "";
}
sb.append("Pixel: ");
double[] coordDbl = new double[2];
coordDbl[0] = imageDisplay.formatValue(coord.asLatLon().x);
coordDbl[1] = imageDisplay.formatValue(coord.asLatLon().y);
// sb.append(coord.asLatLon().toString());
sb.append((new Coordinate(coordDbl[0], coordDbl[1])).toString());
sb.append('\n');
Map<String, Object> map = imageDisplay.interrogate(coord);
for (Map.Entry<String, Object> item : map.entrySet()) {
sb.append(item.getKey() + ": ");
sb.append(item.getValue().toString());
sb.append('\n');
}
return sb.toString();
} catch (TransformException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (FactoryException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
StringBuilder sb = new StringBuilder();
sb.append("** " + this.getLegendStr() + " **\n");
try {
FrameData currFrame = (FrameData) getCurrentFrame();
SolarImageDisplay imageDisplay = currFrame.imageDisplay;
if (imageDisplay == null) {
return "";
}
sb.append("Pixel: ");
double[] coordDbl = new double[2];
coordDbl[0] = imageDisplay.formatValue(coord.asLatLon().x);
coordDbl[1] = imageDisplay.formatValue(coord.asLatLon().y);
sb.append((new Coordinate(coordDbl[0], coordDbl[1])).toString());
sb.append('\n');
Map<String, Object> map = imageDisplay.interrogate(coord);
if (map != null) {
for (Map.Entry<String, Object> item : map.entrySet()) {
sb.append(item.getKey() + ": ");
sb.append(item.getValue().toString());
sb.append('\n');
}
} else {
return "";
}
return sb.toString();
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} catch (FactoryException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return "No Data";
}
@ -710,6 +759,9 @@ public class SolarImageResource extends
cmapParams);
cbarResource.setColorBar(colorBar);
isColorMapChanged = true;
setAllFramesColorMapChanged(isColorMapChanged);
}
@Override
@ -732,6 +784,7 @@ public class SolarImageResource extends
solarImgRscData.setAlpha(imgCap.getAlpha());
solarImgRscData.setBrightness(imgCap.getBrightness());
solarImgRscData.setContrast(imgCap.getContrast());
solarImgRscData.setImageFunction(imageFunction);
issueRefresh();
} else if (object instanceof ColorMapCapability) {
@ -750,6 +803,7 @@ public class SolarImageResource extends
ColorBarFromColormap cBar = solarImgRscData.getColorBar();
cBar.setColorMap(theColorMap);
ColorBarFromColormap colorBar = (ColorBarFromColormap) this.cbarResource
.getResourceData().getColorbar();
if (colorBar != null) {
@ -765,6 +819,7 @@ public class SolarImageResource extends
}
solarImgRscData.getRscAttrSet().setAttrValue("colorBar", cBar);
solarImgRscData.setIsEdited(true);
isColorMapChanged = true;
issueRefresh();
}
@ -816,7 +871,6 @@ public class SolarImageResource extends
ColorMapCapability.class).getColorMapParameters()
.getColorMap());
}
MatchCriteria matchCriteria = SolarImageMatchCriteria
.constructFromResourceData(solarImgRscData);
@ -889,6 +943,16 @@ public class SolarImageResource extends
e1.printStackTrace();
}
if (sRule == null)
throw new VizException(
"Style Rule does not exist for this resource type (instrument: "
+ solarImgRscData.getInstrument()
+ ", wavelength: "
+ solarImgRscData.getWavelength()
+ " and intTime: "
+ solarImgRscData.getIntTime()
+ "). Please add it to solarImageryStyleRules.xml file located under Localization perspective -> NCEP -> Style Rules. ");
scale = ((ImagePreferences) sRule.getPreferences()).getDataScale();
dataMap = ((ImagePreferences) sRule.getPreferences()).getDataMapping();
labelPrefs = ((ImagePreferences) sRule.getPreferences())
@ -1015,4 +1079,78 @@ public class SolarImageResource extends
}
}
protected void setAllFramesColorMapChanged(boolean cMapChanged) {
for (AbstractFrameData frameData : frameDataMap.values()) {
FrameData frame = (FrameData) frameData;
if (frame.imageDisplay != null) {
frame.imageDisplay.setColorMapChanged(cMapChanged);
if (cMapChanged)
frame.imageDisplay.setColorMapParameters(colorMapParams);
}
}
}
public Coordinate getLatLonFromPixel(Coordinate pixelCoord) {
FrameData currentFrame = (FrameData) getCurrentFrame();
if (currentFrame != null) {
SolarImageDisplay currentDisplay = ((FrameData) getCurrentFrame()).imageDisplay;
if (currentDisplay != null) {
return currentDisplay.getLatLonFromPixel(pixelCoord);
}
}
return null;
}
public void setVirtualCursor(Coordinate virtualCursorLatLon) {
FrameData currentFrame = (FrameData) getCurrentFrame();
if (currentFrame != null) {
SolarImageDisplay currentDisplay = ((FrameData) getCurrentFrame()).imageDisplay;
if (currentDisplay != null) {
virtualCursor = currentDisplay
.getPixelCoordFromLatLon(virtualCursorLatLon);
if (virtualCursor != null) {
this.sampleCoord = new ReferencedCoordinate(
this.virtualCursor);
// }
// keep '+' with sampling
double[] out = this.getDescriptor().worldToPixel(
new double[] { virtualCursor.x, virtualCursor.y });
this.virtualCursor = new Coordinate(out[0], out[1]);
}
}
}
}
protected void drawVirtualCursor(PaintProperties paintProps,
IGraphicsTarget target) throws VizException {
// Calculate scale for image
double screenToWorldRatio = paintProps.getCanvasBounds().width
/ paintProps.getView().getExtent().getWidth();
double outsideValue = 6 / screenToWorldRatio;
if (virtualCursor != null) {
target.drawLine(virtualCursor.x + outsideValue,
virtualCursor.y + 1, 0.0, virtualCursor.x - outsideValue,
virtualCursor.y + 1, 0.0, rgbB, 1.0f);
target.drawLine(virtualCursor.x + 1,
virtualCursor.y + outsideValue, 0.0, virtualCursor.x + 1,
virtualCursor.y - outsideValue, 0.0, rgbB, 1.0f);
target.drawLine(virtualCursor.x + outsideValue, virtualCursor.y,
0.0, virtualCursor.x - outsideValue, virtualCursor.y, 0.0,
rgbW, 1.0f);
target.drawLine(virtualCursor.x, virtualCursor.y + outsideValue,
0.0, virtualCursor.x, virtualCursor.y - outsideValue, 0.0,
rgbW, 1.0f);
}
}
}

View file

@ -1,12 +1,12 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.rsc;
import java.text.ParseException;
import java.text.ParsePosition;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
import gov.noaa.nws.ncep.viz.ui.display.ColorBarFromColormap;
import java.text.ParseException;
import java.text.ParsePosition;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import javax.xml.bind.annotation.XmlAccessType;
@ -20,151 +20,190 @@ import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
/**
* The resource data class for Solar Image.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/21/2013 958 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "SolarImageResourceData")
public class SolarImageResourceData extends AbstractNatlCntrsRequestableResourceData {
public class SolarImageResourceData extends
AbstractNatlCntrsRequestableResourceData {
private static final String instrumentParam = "instrument";
private static final String wavelengthParam = "wavelength";
private static final String intTimeParam = "intTime";
private static final String instrumentParam = "instrument";
@XmlElement
private Float alpha;
private static final String wavelengthParam = "wavelength";
@XmlElement
private Float brightness;
@XmlElement
private Float contrast;
@XmlElement
private static final String intTimeParam = "intTime";
@XmlElement
private Float alpha;
@XmlElement
private Float brightness;
@XmlElement
private Float contrast;
@XmlElement
private Integer cylindrical;
@XmlElement
private String colorMapName;
@XmlElement
@XmlElement
private ColorBarFromColormap colorBar;
@XmlElement
private String displayUnitStr;
private Unit<?> displayUnit;
@XmlElement
private String displayUnitStr;
@XmlElement
private String imageFunction;
private Unit<?> displayUnit;
public SolarImageResourceData() {
super();
// called by AbstractVizResource.getName()
// and we delegate back to the resource
this.nameGenerator = new AbstractNameGenerator() {
@Override
public String getName(AbstractVizResource<?, ?> resource) {
return ((SolarImageResource)resource).getLegendStr();
return ((SolarImageResource) resource).getLegendStr();
}
};
}
@Override
public NcDisplayType[] getSupportedDisplayTypes() {
return new NcDisplayType[] { NcDisplayType.SOLAR_DISPLAY };
}
// The following methods assume that the constraints in the metadata map
// are are for 'exact' matches. ie. that the one constraint value is the value
// that will be queried.
public String getInstrument() {
return ( metadataMap.containsKey(instrumentParam) ?
metadataMap.get(instrumentParam).getConstraintValue() : "" );
@Override
public NcDisplayType[] getSupportedDisplayTypes() {
return new NcDisplayType[] { NcDisplayType.SOLAR_DISPLAY };
}
// The following methods assume that the constraints in the metadata map
// are are for 'exact' matches. ie. that the one constraint value is the
// value
// that will be queried.
public String getInstrument() {
return (metadataMap.containsKey(instrumentParam) ? metadataMap.get(
instrumentParam).getConstraintValue() : "");
}
public String getWavelength() {
return ( metadataMap.containsKey(wavelengthParam) ?
metadataMap.get(wavelengthParam).getConstraintValue() : "" );
return (metadataMap.containsKey(wavelengthParam) ? metadataMap.get(
wavelengthParam).getConstraintValue() : "");
}
public String getIntTime() {
return ( metadataMap.containsKey(intTimeParam) ?
metadataMap.get(intTimeParam).getConstraintValue() : "" );
return (metadataMap.containsKey(intTimeParam) ? metadataMap.get(
intTimeParam).getConstraintValue() : "");
}
@Override
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
return new SolarImageResource(this, loadProperties);
}
public Unit<?> getDisplayUnit() {
if( displayUnit == null ) {
setDisplayUnitStr( displayUnitStr );
}
return displayUnit;
}
public String getDisplayUnitStr() {
return displayUnitStr;
}
public String getImageFunction() {
public void setDisplayUnitStr(String dispUnitStr) {
this.displayUnitStr = dispUnitStr;
return imageFunction;
}
if( displayUnit == null ) {
if( displayUnitStr != null ) {
try {
displayUnit = UnitFormat.getUCUMInstance().parseSingleUnit(
displayUnitStr, new ParsePosition(0));
} catch (ParseException e) {
System.out.println("Unable parse display units : " + displayUnitStr );
}
}
}
}
public String getColorMapName() {
return colorMapName;
}
public void setImageFunction(String imageFunction) {
this.imageFunction = imageFunction;
}
@Override
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
return new SolarImageResource(this, loadProperties);
}
public Unit<?> getDisplayUnit() {
if (displayUnit == null) {
setDisplayUnitStr(displayUnitStr);
}
return displayUnit;
}
public String getDisplayUnitStr() {
return displayUnitStr;
}
public void setDisplayUnitStr(String dispUnitStr) {
this.displayUnitStr = dispUnitStr;
if (displayUnit == null) {
if (displayUnitStr != null) {
try {
displayUnit = UnitFormat.getUCUMInstance().parseSingleUnit(
displayUnitStr, new ParsePosition(0));
} catch (ParseException e) {
System.out.println("Unable parse display units : "
+ displayUnitStr);
}
}
}
}
public String getColorMapName() {
return colorMapName;
}
public void setColorMapName(String cmapName) {
colorMapName = cmapName;
}
public void setColorMapName(String cmapName) {
colorMapName = cmapName;
}
public ColorBarFromColormap getColorBar() {
return colorBar;
}
return colorBar;
}
public void setColorBar(ColorBarFromColormap cBar) {
this.colorBar = cBar;
}
public void setColorBar(ColorBarFromColormap cBar) {
this.colorBar = cBar;
}
public Float getAlpha() {
return alpha;
}
return alpha;
}
public void setAlpha(Float alpha) {
this.alpha = alpha;
}
public void setAlpha(Float alpha) {
this.alpha = alpha;
}
public Float getBrightness() {
return brightness;
}
public void setBrightness(Float brightness) {
this.brightness = brightness;
}
public Float getBrightness() {
return brightness;
}
public Float getContrast() {
return contrast;
}
public void setContrast(Float contrast) {
this.contrast = contrast;
}
public void setBrightness(Float brightness) {
this.brightness = brightness;
}
public Integer getCylindrical() {
return cylindrical;
}
public void setCylindrical(Integer cylindrical) {
this.cylindrical = cylindrical;
}
public Float getContrast() {
return contrast;
}
public void setContrast(Float contrast) {
this.contrast = contrast;
}
@Override
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
return false;
@ -183,7 +222,7 @@ public class SolarImageResourceData extends AbstractNatlCntrsRequestableResource
&& this.colorMapName.equals(other.colorMapName) == false) {
return false;
}
if (this.displayUnitStr != null && other.displayUnitStr == null) {
return false;
} else if (this.displayUnitStr == null && other.displayUnitStr != null) {
@ -192,29 +231,30 @@ public class SolarImageResourceData extends AbstractNatlCntrsRequestableResource
&& this.displayUnitStr.equals(other.displayUnitStr) == false) {
return false;
}
if ( (this.alpha != null && other.alpha == null)
|| (this.alpha == null && other.alpha != null)
|| (this.alpha != null && this.alpha.equals(other.alpha) == false)){
return false;
}
if ( (this.brightness != null && other.brightness == null)
|| (this.brightness == null && other.brightness != null)
|| (this.brightness != null && this.brightness.equals(other.brightness) == false)){
return false;
}
if ( (this.contrast != null && other.contrast == null)
|| (this.contrast == null && other.contrast != null)
|| (this.contrast != null && this.contrast.equals(other.contrast) == false)){
return false;
}
if ((this.alpha != null && other.alpha == null)
|| (this.alpha == null && other.alpha != null)
|| (this.alpha != null && this.alpha.equals(other.alpha) == false)) {
return false;
}
if ((this.brightness != null && other.brightness == null)
|| (this.brightness == null && other.brightness != null)
|| (this.brightness != null && this.brightness
.equals(other.brightness) == false)) {
return false;
}
if ((this.contrast != null && other.contrast == null)
|| (this.contrast == null && other.contrast != null)
|| (this.contrast != null && this.contrast
.equals(other.contrast) == false)) {
return false;
}
return true;
}
}

View file

@ -1,13 +1,12 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.util;
import com.raytheon.uf.viz.core.exception.VizException;
import nom.tam.fits.BasicHDU;
import nom.tam.fits.Header;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Represents the image data of a SolarImageRecord object.
* Represents the image header data of a SolarImageRecord object.
*
* <pre>
* SOFTWARE HISTORY
@ -21,62 +20,83 @@ import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
* @version 1.0
*/
public class HeaderData {
private Header header;
private int nx;
private Header header;
private int nx;
private int ny;
private int dim;
private double hgln; //_OBS
private double hgln;
private double hglt;
private double crln;
private double crlt;
//private double hcit, hcix, haex, haey, heex, heey, heqx, heqy,;
private double dsun; //distance between the observer and sun image, ~D0
// private double hcit, hcix, haex, haey, heex, heey, heqx, heqy,;
private double dsun; // distance between the observer and sun image, ~D0
private double carRot; //
private double solarB0;
private double solarL0;
private double rsun; //fits rsun
private double B0;
private double L0;
private double solarB0;
private double solarL0;
private double rsun; // fits rsun
private double bitpix;
private double bscale;
private double bzero;
private String telescope;
/**
* @param record
*/
public HeaderData(SolarImageRecord record) throws VizException {
try {
BasicHDU hdu = SolarImageUtil.getImageHDU(record);
if (hdu != null) {
int[] axes = hdu.getAxes();
if (axes != null && axes.length != 2) {
// Expecting 2 dimensional image at this time
throw new VizException(
"The record does not contain a 2 dimensional image.");
}
this.header = hdu.getHeader();
this.nx = axes[1];
this.ny = axes[0];
this.dim = header.getIntValue("NAXIS");
this.hgln = header.getDoubleValue("HGLN_OBS", 0.0);
this.hglt = header.getDoubleValue("HGLT_OBS", 0.0);
this.crln = header.getDoubleValue("CRLN_OBS", 0.0);
this.crlt = header.getDoubleValue("CRLT_OBS", 0.0);
this.dsun = header.getDoubleValue("DSUN_OBS", 1392000000);
this.carRot = header.getDoubleValue("CAR_ROT", 0.0);
this.solarB0 = header.getDoubleValue("SOLAR-B0", 0.0);
this.solarL0 = header.getDoubleValue("SOLAR-L0", 0.0);
}
}
catch (Exception e) {
throw new VizException("Error getting SolarImageData from SolarImageRecord.");
}
public HeaderData(BasicHDU hdu) throws VizException {
try {
// BasicHDU hdu = SolarImageUtil.getImageHDU(record);
if (hdu != null) {
int[] axes = hdu.getAxes();
if (axes != null && axes.length != 2) {
// Expecting 2 dimensional image at this time
throw new VizException(
"The record does not contain a 2 dimensional image.");
}
this.header = hdu.getHeader();
this.nx = axes[1];
this.ny = axes[0];
this.dim = header.getIntValue("NAXIS");
this.hgln = header.getDoubleValue("HGLN_OBS", 0.0);
this.hglt = header.getDoubleValue("HGLT_OBS", 0.0);
this.crln = header.getDoubleValue("CRLN_OBS", 0.0);
this.crlt = header.getDoubleValue("CRLT_OBS", 0.0);
this.dsun = header.getDoubleValue("DSUN_OBS", 1392000000);
this.carRot = header.getDoubleValue("CAR_ROT", 0.0);
this.solarB0 = header.getDoubleValue("SOLAR-B0", 0.0);
this.solarL0 = header.getDoubleValue("SOLAR-L0", 0.0);
this.bitpix = hdu.getBitPix();
this.bscale = hdu.getBScale();
this.bzero = hdu.getBZero();
this.telescope = header.getStringValue("TELESCOP");
}
} catch (Exception e) {
throw new VizException(
"Error getting SolarImageData from SolarImageRecord.");
}
}
/**
* @return the nx
*/
@ -203,31 +223,33 @@ public class HeaderData {
public double getSolarB0() {
return solarB0;
}
/**
* @return the header
*/
public double getSolarL0() {
return solarL0;
}
/**
* @return the rsun
*/
public double getRsun() {
rsun = 0.0;
if (header.getStringValue("TELESCOP").startsWith("SDO"))
rsun = header.getDoubleValue("RSUN_OBS");
else if (header.getStringValue("TELESCOP").startsWith("STEREO"))
rsun = header.getDoubleValue("RSUN");
else if (header.getStringValue("TELESCOP").startsWith("SOHO")
&& header.getStringValue("INSTRUME").startsWith("EIT"))
rsun = header.getDoubleValue("SOLAR_R") * header.getDoubleValue("CDELT1");
else if (header.getStringValue("TELESCOP").startsWith("NSO"))
rsun = header.getDoubleValue("RADIUS", header.getDoubleValue("SOLAR-R"));
else if (header.getStringValue("TELESCOP").startsWith("GOES"))
rsun = calculateRsun();
rsun = 0.0;
if (telescope.startsWith("SDO"))
rsun = header.getDoubleValue("RSUN_OBS");
else if (telescope.startsWith("STEREO"))
rsun = header.getDoubleValue("RSUN");
else if (telescope.startsWith("SOHO")
&& header.getStringValue("INSTRUME").startsWith("EIT"))
rsun = header.getDoubleValue("SOLAR_R")
* header.getDoubleValue("CDELT1");
else if (telescope.startsWith("NSO"))
rsun = header.getDoubleValue("RADIUS",
header.getDoubleValue("SOLAR-R"));
else if (telescope.startsWith("GOES"))
rsun = calculateRsun();
return rsun;
}
@ -243,8 +265,9 @@ public class HeaderData {
* @return the rsun
*/
public double getCarRot() {
return carRot;
return carRot;
}
/**
* @param rsun
* the rsun to set??
@ -252,185 +275,205 @@ public class HeaderData {
public void setCarRot(double carRot) {
this.carRot = carRot;
}
/**
* @return the rsun
*/
public double getJulianDate() {
String date = ""; //'2012/03/07T17:34:57.160'
int y=0, m = 0, d = 0, hh = 0, mm = 0, ss = 0;
double jd = 0.0;
date = header.getStringValue("DATE_OBS");
if (date == null || date.equalsIgnoreCase(""))
date = header.getStringValue("DATE-OBS");
if (date != null && date.length() <= 10 ) //LASCO dateObs=Date +Time
date = date + "T" + header.getStringValue("TIME-OBS");
y = Integer.valueOf(date.substring(0,4));
m = Integer.valueOf(date.substring(5,7));
d = Integer.valueOf(date.substring(8,10));
hh = Integer.valueOf(date.substring(11,13));
mm = Integer.valueOf(date.substring(14,16));
ss = Integer.valueOf(date.substring(17,19));
double msec = hh*3600*1000 +mm*60*1000 +ss*1000;
jd = 367*y-7*(y+(m+9)/12)/4-3*((y+(m-9)/7)/100+1)/4 +275*m/9+d+1721029 -0.5 + msec/86400000;
//System.out.println("****jd " +jd +" "+m +" "+d +" "+hh +" "+mm+" "+ss);
return jd;
String date = ""; // '2012/03/07T17:34:57.160'
int y = 0, m = 0, d = 0, hh = 0, mm = 0, ss = 0;
double jd = 0.0;
date = header.getStringValue("DATE_OBS");
if (date == null || date.equalsIgnoreCase(""))
date = header.getStringValue("DATE-OBS");
if (date != null && date.length() <= 10) // LASCO dateObs=Date +Time
date = date + "T" + header.getStringValue("TIME-OBS");
y = Integer.valueOf(date.substring(0, 4));
m = Integer.valueOf(date.substring(5, 7));
d = Integer.valueOf(date.substring(8, 10));
hh = Integer.valueOf(date.substring(11, 13));
mm = Integer.valueOf(date.substring(14, 16));
ss = Integer.valueOf(date.substring(17, 19));
double msec = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000;
jd = 367 * y - 7 * (y + (m + 9) / 12) / 4 - 3
* ((y + (m - 9) / 7) / 100 + 1) / 4 + 275 * m / 9 + d + 1721029
- 0.5 + msec / 86400000;
// System.out.println("****jd " +jd +" "+m +" "+d +" "+hh
// +" "+mm+" "+ss);
return jd;
}
public double calculateRsun() {
double jd = 0.0, t = 0.0;
jd = getJulianDate();
//Julian Centuries from 1900.0:
t = (jd - 2415020)/36525;
//Carrington Rotation Number:
double carr = (1./27.2753)*(jd-2398167.0) + 1.0;
//System.out.println("***carr "+carr);
//OLD = 349.03 - (360.* carr / 27.2753),
//Fit#1 = f + X/g + a*SIN(2*π*X/e) + b*SIN(4*π*X/e) + h*SIN(6*π*X/e)
// + c*COS(2*π*X/e) + d*COS(4*π*X/e) + i*COS(6*π*X/e)
double jd = 0.0, t = 0.0;
jd = getJulianDate();
// Julian Centuries from 1900.0:
t = (jd - 2415020) / 36525;
// Carrington Rotation Number:
double carr = (1. / 27.2753) * (jd - 2398167.0) + 1.0;
// OLD = 349.03 - (360.* carr / 27.2753),
// Fit#1 = f + X/g + a*SIN(2*π*X/e) + b*SIN(4*π*X/e) + h*SIN(6*π*X/e)
// + c*COS(2*π*X/e) + d*COS(4*π*X/e) + i*COS(6*π*X/e)
//Geometric Mean Longitude (deg):
double mnl = 279.69668 + 36000.76892*t + 0.0003025*t*t;
mnl = mnl % 360;
//Mean anomaly (deg):
double mna = 358.47583 + 35999.04975*t - 0.000150*t*t - 0.0000033*t*t*t;
mna = mna % 360;
//Eccentricity of orbit:
double e = 0.01675104 - 0.0000418*t - 0.000000126*t*t;
//Sun's equation of center (deg):
double c = (1.919460 - 0.004789*t - 0.000014*t*t)* Math.sin(Math.toRadians(mna)) +
(0.020094 - 0.000100*t)* Math.sin(Math.toRadians(2*mna)) +
0.000293 * Math.sin(Math.toRadians(3*mna));
// Sun's true geometric longitude (deg)
// (Refered to the mean equinox of date. Question: Should the higher
// accuracy terms from which app_long is derived be added to true_long?)
// true_long = (mnl + c) mod 360d0
//Sun's true anomaly (deg):
double ta = (mna + c) % 360;
// Geometric Mean Longitude (deg):
double mnl = 279.69668 + 36000.76892 * t + 0.0003025 * t * t;
mnl = mnl % 360;
//Sun's radius vector (AU). There are a set of higher accuracy
//terms not included here. The values calculated here agree with the example in the book:
double dist = 1.0000002*(1.0 - e*e)/(1.0 + e* Math.cos(Math.toRadians(ta)));
//Semidiameter (arc sec):
double sd = 959.63/dist;
//System.out.println("****sd " +sd );
// Mean anomaly (deg):
double mna = 358.47583 + 35999.04975 * t - 0.000150 * t * t - 0.0000033
* t * t * t;
mna = mna % 360;
return sd;
// Eccentricity of orbit:
double e = 0.01675104 - 0.0000418 * t - 0.000000126 * t * t;
// Sun's equation of center (deg):
double c = (1.919460 - 0.004789 * t - 0.000014 * t * t)
* Math.sin(Math.toRadians(mna)) + (0.020094 - 0.000100 * t)
* Math.sin(Math.toRadians(2 * mna)) + 0.000293
* Math.sin(Math.toRadians(3 * mna));
// Sun's true geometric longitude (deg)
// (Refered to the mean equinox of date. Question: Should the higher
// accuracy terms from which app_long is derived be added to true_long?)
// true_long = (mnl + c) mod 360d0
// Sun's true anomaly (deg):
double ta = (mna + c) % 360;
// Sun's radius vector (AU). There are a set of higher accuracy
// terms not included here. The values calculated here agree with the
// example in the book:
double dist = 1.0000002 * (1.0 - e * e)
/ (1.0 + e * Math.cos(Math.toRadians(ta)));
// Semidiameter (arc sec):
double sd = 959.63 / dist;
// System.out.println("****sd " +sd );
return sd;
}
public double[] getL0B0() {
double L0 = 0.0;
double jd = getJulianDate();
double radian = 180/Math.PI;
double theta = (jd-2398220)*360/25.38;
double inc = 7.25/radian;
double k = (73.6667+1.3958333*(jd-2396758)/36525)/radian;
double t = (jd-2451545)/36525;
L0 = 280.46645+36000.76983*t+0.0003032*t*t;
double M = 357.52910+35999.05030*t-0.0001559*t*t-0.00000048*t*t*t;
double Mr = M/radian;
double C = (1.914600-0.004817*t-0.000014*t*t)*Math.sin(Mr)+(0.019993-0.000101*t)*Math.sin(2*Mr)+0.000290*Math.sin(3*Mr);
double sunL = L0+C;
double omega = 125.04-1934.136*t;
double lngtd = sunL-0.00569-0.00478*Math.sin(omega/radian);
double lngtdr = lngtd/radian;
double diffk = (lngtdr-k);
double etay = -Math.sin(diffk)*Math.cos(inc);
double jd = getJulianDate();
double radian = 180 / Math.PI;
double theta = (jd - 2398220) * 360 / 25.38;
double inc = 7.25 / radian;
double k = (73.6667 + 1.3958333 * (jd - 2396758) / 36525) / radian;
double t = (jd - 2451545) / 36525;
L0 = 280.46645 + 36000.76983 * t + 0.0003032 * t * t;
double M = 357.52910 + 35999.05030 * t - 0.0001559 * t * t - 0.00000048
* t * t * t;
double Mr = M / radian;
double C = (1.914600 - 0.004817 * t - 0.000014 * t * t) * Math.sin(Mr)
+ (0.019993 - 0.000101 * t) * Math.sin(2 * Mr) + 0.000290
* Math.sin(3 * Mr);
double sunL = L0 + C;
double omega = 125.04 - 1934.136 * t;
double lngtd = sunL - 0.00569 - 0.00478 * Math.sin(omega / radian);
double lngtdr = lngtd / radian;
double diffk = (lngtdr - k);
double etay = -Math.sin(diffk) * Math.cos(inc);
double etax = -Math.cos(diffk);
double eta = (Math.atan2(etay,etax))*radian;
double B0r =Math.asin( Math.sin(diffk)*Math.sin(inc)); //central latitude
double B0 = B0r*radian;
L0 = eta - theta;
double eta = (Math.atan2(etay, etax)) * radian;
double B0r = Math.asin(Math.sin(diffk) * Math.sin(inc)); // central
// latitude
double B0 = B0r * radian;
L0 = eta - theta;
L0 = truncate(L0);
double[] L0B0 = new double[2];
double[] L0B0 = new double[2];
L0B0[0] = L0;
L0B0[1] = B0;
return L0B0;
}
public double getL0() {
double L0 = 0;
if (!isStereo()) {
L0 = getL0B0()[0];
}
else {
L0 = crln - hgln;
}
return L0;
double L0 = 0;
if (!isStereo()) {
L0 = getL0B0()[0];
} else {
L0 = crln - hgln;
}
return L0;
}
public double getB0() {
double B0 = 0;
B0 = getL0B0()[1];
return B0;
}
public double truncate(double angle) {
double n = Math.floor(angle/360);
double tangle = angle-n*360;
double n = Math.floor(angle / 360);
double tangle = angle - n * 360;
return tangle;
}
public boolean isStereo() {
if (header.getStringValue("TELESCOP").startsWith("STEREO"))
return true;
if (header.getStringValue("TELESCOP").startsWith("STEREO"))
return true;
return false;
}
public boolean isSdoAia() {
if (header.getStringValue("TELESCOP").startsWith("SDO/AIA"))
return true;
if (header.getStringValue("TELESCOP").startsWith("SDO/AIA"))
return true;
return false;
}
public boolean isSdoHmi() {
if (header.getStringValue("TELESCOP").startsWith("SDO/HMI"))
return true;
if (header.getStringValue("TELESCOP").startsWith("SDO/HMI"))
return true;
return false;
}
public boolean isGoes() {
if (header.getStringValue("TELESCOP").startsWith("SXI"))
return true;
if (header.getStringValue("TELESCOP").startsWith("SXI"))
return true;
return false;
}
public boolean isNso() {
if (header.getStringValue("TELESCOP").startsWith("NSO"))
return true;
if (header.getStringValue("TELESCOP").startsWith("NSO"))
return true;
return false;
}
public boolean isSoho() {
if (header.getStringValue("TELESCOP").startsWith("SOHO"))
return true;
if (header.getStringValue("TELESCOP").startsWith("SOHO"))
return true;
return false;
}
/**
* @return the header
*/
@ -446,4 +489,28 @@ public class HeaderData {
this.header = header;
}
public double getBitpix() {
return bitpix;
}
public void setBitpix(double bitpix) {
this.bitpix = bitpix;
}
public double getBscale() {
return bscale;
}
public void setBscale(double bscale) {
this.bscale = bscale;
}
public double getBzero() {
return bzero;
}
public void setBzero(double bzero) {
this.bzero = bzero;
}
}

View file

@ -2,9 +2,6 @@ package gov.noaa.nws.ncep.viz.rsc.solarimage.util;
import com.raytheon.uf.viz.core.exception.VizException;
import nom.tam.fits.BasicHDU;
import nom.tam.fits.Header;
import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
/**
* Represents the image data of a SolarImageRecord object.
*
@ -13,102 +10,93 @@ import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
* Date Ticket# Engineer Description
* ------------ ---------- -------------- --------------------------
* 02/07/2013 958 sgurung, qzhou Initial creation.
* 11/12/2013 958 qzhou, sgurung removed Reverse order of image, removed imageArrays, hdu, header.
*
* </pre>
*
* @author sgurung, qzhou
* @version 1.0
*/
public class ImageData {
private int nx;
private int nx;
private int ny;
private int bitpix;
private double bscale;
private double bzero;
private float[] imageValues;
private float[][] imageArrays;
private Header header;
private float[] imageValues;
/**
* @param record
*/
public ImageData(SolarImageRecord record) throws VizException {
try {
BasicHDU hdu = SolarImageUtil.getImageHDU(record);
if (hdu != null) {
int[] axes = hdu.getAxes();
if (axes != null && axes.length != 2) {
// Expecting 2 dimensional image at this time
throw new VizException(
"The record does not contain a 2 dimensional image.");
}
this.header = hdu.getHeader();
this.nx = axes[1];
this.ny = axes[0];
this.bitpix = hdu.getBitPix();
this.bscale = hdu.getBScale();
this.bzero = hdu.getBZero();
Object imgData = hdu.getKernel();
float[][] array = null;
if (imgData instanceof float[][]) {
array = (float[][]) imgData;
} else if (imgData instanceof int[][]) {
array = new float[ny][nx];
int[][] tmp = (int[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else if (imgData instanceof short[][]) {
array = new float[ny][nx];
short[][] tmp = (short[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else if (imgData instanceof byte[][]) {
array = new float[ny][nx];
byte[][] tmp = (byte[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else {
String msg = "SolarImageData: Unrecognized imgDatatype: "
+ imgData.getClass().getCanonicalName();
throw new VizException(msg);
}
int n = 0;
float[] imgDataRec = new float[nx * ny];
for (int i = ny - 1; i >= 0; i--) { // Reverse order of rows
for (int j = 0; j < nx; j++) {
imgDataRec[n++] = array[i][j];
}
}
this.imageValues = imgDataRec;
this.imageArrays = array;
}
}
catch (Exception e) {
throw new VizException("Error getting SolarImageData from SolarImageRecord.");
}
public ImageData(int nx, int ny, double bitpix, double bscale,
double bzero, Object imgData) throws VizException {
try {
// BasicHDU hdu = SolarImageUtil.getImageHDU(record);
if (imgData != null) {
this.nx = nx;
this.ny = ny;
// this.header = hdu.getHeader();
// Object imgData = hdu.getKernel();
float[][] array = null;
if (imgData instanceof float[][]) {
array = (float[][]) imgData;
} else if (imgData instanceof int[][]) {
array = new float[ny][nx];
int[][] tmp = (int[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else if (imgData instanceof short[][]) {
array = new float[ny][nx];
short[][] tmp = (short[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else if (imgData instanceof byte[][]) {
array = new float[ny][nx];
byte[][] tmp = (byte[][]) imgData;
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
array[i][j] = (float) (bscale * tmp[i][j] + bzero);
}
}
} else {
String msg = "SolarImageData: Unrecognized imgDatatype: "
+ imgData.getClass().getCanonicalName();
throw new VizException(msg);
}
int n = 0;
float[] imgDataRec = new float[nx * ny];
// for (int i = ny - 1; i >= 0; i--) { // Reverse order of rows
for (int i = 0; i < ny; i++) {
for (int j = 0; j < nx; j++) {
imgDataRec[n++] = array[i][j];
}
}
this.imageValues = imgDataRec;
// this.imageArrays = array;
}
} catch (Exception e) {
throw new VizException(
"Error getting SolarImageData from SolarImageRecord.");
}
}
public ImageData() {
}
/**
* @return the nx
*/
@ -139,52 +127,6 @@ public class ImageData {
this.ny = ny;
}
/**
* @return the bitpix
*/
public int getBitpix() {
return bitpix;
}
/**
* @param bitpix
* the bitpix to set
*/
public void setBitpix(int bitpix) {
this.bitpix = bitpix;
}
/**
* @return the bscale
*/
public double getBscale() {
return bscale;
}
/**
* @param bscale
* the bscale to set
*/
public void setBscale(double bscale) {
this.bscale = bscale;
}
/**
* @return the bzero
*/
public double getBzero() {
return bzero;
}
/**
* @param bzero
* the bzero to set
*/
public void setBzero(double bzero) {
this.bzero = bzero;
}
/**
* @return the imageValues
*/
@ -199,35 +141,5 @@ public class ImageData {
public void setImageValues(float[] imageValues) {
this.imageValues = imageValues;
}
/**
* @return the imageValues
*/
public float[][] getImageArrays() {
return imageArrays;
}
/**
* @param imageValues
* the imageValues to set
*/
public void setImageArrays(float[][] imageArrays) {
this.imageArrays = imageArrays;
}
/**
* @return the header
*/
public Header getHeader() {
return header;
}
/**
* @param header
* the header to set
*/
public void setHeader(Header header) {
this.header = header;
}
}

View file

@ -0,0 +1,60 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.util;
/**
* <pre>
* Provide image functions. Format:
* imageFunction=functionName(parameter)
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 12/17/2013 1046 qzhou initial
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class ImageFunctionParser {
public static String[] parse(String imageFunction) {
String[] parse = null;
String regex = "\\(|,|\\)";
if (imageFunction != "")
parse = imageFunction.split(regex);
return parse;
}
public static String getFuncName(String imageFunction) {
String funcName = null;
String[] parse = parse(imageFunction);
if (parse != null && parse.length >= 1)
funcName = parse[0];
return funcName;
}
public static int getFuncParamNum(String imageFunction) {
String[] parse = parse(imageFunction);
if (parse.length > 1)
return parse.length - 1;
else
return 0;
}
public static String getFuncParam(String imageFunction, int paramOrder) {
String param = null;
String[] parse = parse(imageFunction);
if (parse != null && parse.length > paramOrder)
param = parse[paramOrder];
return param;
}
}

View file

@ -5,17 +5,16 @@ import gov.noaa.nws.ncep.common.dataplugin.solarimage.SolarImageRecord;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Calendar;
import nom.tam.fits.BasicHDU;
import nom.tam.fits.Fits;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.exception.VizException;
import nom.tam.fits.BasicHDU;
import nom.tam.fits.Fits;
import nom.tam.fits.FitsException;
/**
* Provides utility methods to get data from hdf5 and convert it to Fits format.
*
@ -32,57 +31,51 @@ import nom.tam.fits.FitsException;
*/
public class SolarImageUtil {
public static void populateRawData(SolarImageRecord record) throws FileNotFoundException,
StorageException {
//System.out.println("Retrieving SolarImage data from HDF5...");
public static void populateRawData(SolarImageRecord record)
throws FileNotFoundException, StorageException {
File loc = HDF5Util.findHDF5Location(record);
IDataStore dataStore = DataStoreFactory.getDataStore(loc);
record.retrieveFromDataStore(dataStore);
}
public static Fits convertToFits(SolarImageRecord record) throws Exception {
populateRawData(record);
if (record.getRawData() != null) {
try {
Fits fits = new Fits(new ByteArrayInputStream(
record.getRawData()));
File loc = HDF5Util.findHDF5Location(record);
//Long t0 = System.currentTimeMillis();
IDataStore dataStore = DataStoreFactory.getDataStore(loc);
//System.out.println("--- solarimage: time to get datastore: " + (System.currentTimeMillis() - t0));
//t0 = System.currentTimeMillis();
record.retrieveFromDataStore(dataStore);
//System.out.println("--- solarimage: time to retrieve from datastore: " + (System.currentTimeMillis() - t0));
}
public static Fits convertToFits(SolarImageRecord record) throws Exception {
populateRawData(record);
if (record.getRawData() != null) {
try{
Fits fits = new Fits(new ByteArrayInputStream(record.getRawData()));
return fits;
}
catch (Exception e) {
System.out.println("Error converting SolarImageRecord to Fits: " + e.getMessage());
}
} catch (Exception e) {
System.out
.println("Error converting SolarImageRecord to Fits: "
+ e.getMessage());
}
}
return null;
}
public static BasicHDU getImageHDU(SolarImageRecord record) throws Exception {
Fits fits = convertToFits(record);
if (fits != null) {
try {
return fits.getHDU(record.getImageHDUNum());
} catch (FitsException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return null;
}
return null;
}
public static BasicHDU getImageHDU(SolarImageRecord record)
throws VizException {
try {
Fits fits = convertToFits(record);
if (fits != null)
return fits.getHDU(record.getImageHDUNum());
} catch (Exception e) {
throw new VizException("Error reading data from HDF5: "
+ e.getMessage());
}
return null;
}
}

View file

@ -17,173 +17,276 @@ import gov.noaa.nws.ncep.viz.rsc.solarimage.util.HeaderData;
* @version 1.0
*/
public class CSConversions {
private int dim = 0;
public HeaderData headerData;
private int dim = 0;
private double rsun;
private double dsun;
private double hgln;
private double hglt;
private double crln;
private double B0;
private double L0;
private boolean isStereo = false;
public CSConversions(HeaderData headerData) {
this.headerData = headerData;
dim = headerData.getDim();
}
dim = headerData.getDim();
rsun = headerData.getRsun();
dsun = headerData.getDsun();
hglt = headerData.getHglt();
crln = headerData.getCrln();
hgln = headerData.getHgln();
B0 = headerData.getB0(); // -headerData.getL0B0()[1]. tested aia euvi
L0 = headerData.getL0();
isStereo = headerData.isStereo();
}
public double[] heliocentricToHeliographic(double[] cs, boolean isCarrington) {
/* Equations used:
* r2= x2 + y 2 + z2 ,
* Θ = sin1 ((y cos B0 + z sin B0 )/r),
* Φ = Φ0 + arg(z cos B0 y sin B0 , x), Where arg( x, y) = tan1 (y/ x) .
*/
double[] helio = new double[dim];
double r = headerData.getRsun();
double z = (double) Math.sqrt(r*r -cs[0]*cs[0] -cs[1]*cs[1]);
double b0 = headerData.getHglt();
double a0 = headerData.getHgln();
double crln = headerData.getCrln();
double L0 = 0.0;
if (!headerData.isStereo()) {
b0 = headerData.getL0B0()[1];
}
if (isCarrington) {
L0 = headerData.getL0();
}
double temp = (double) ((cs[1] * Math.cos(Math.toRadians(b0)) + z * Math.sin(Math.toRadians(b0)) )/ r); //lat
helio[1] = (double) Math.asin(temp);
helio[1] = Math.toDegrees(helio[1]);
temp = (double) ((cs[0]) / ( z * Math.cos(Math.toRadians(b0)) - cs[1] * Math.sin(Math.toRadians(b0)) ));
helio[0] = (double) (Math.toRadians(a0) + Math.atan(temp));
helio[0] = Math.toDegrees(helio[0]) + L0;
if (helio[0] < -180)
helio[0] = helio[0] + 360;
if (helio[0] > 180)
helio[0] = helio[0] - 360;
if (helio[0] < 0)
helio[0] = helio[0] + 360;
return helio;
}
public double[] heliographicToHeliocentric(double[] cs, boolean isCarrington) {
/*
* Equations used: r2= x2 + y 2 + z2 , Θ = sin1 ((y cos B0 + z sin B0
* )/r), Φ = Φ0 + arg(z cos B0 y sin B0 , x), Where arg( x, y) = tan1
* (y/ x) .
*/
double[] helio = new double[dim];
double r = this.rsun;
/* Equations used:
* centric[0] = r cos Θ sin(Φ Φ0 ),
* centric[1] = r[sin Θ cos B0 cos Θ cos(Φ Φ0 ) sin B0 ],
* z = r[sin Θ sin B0 + cos Θ cos(Φ Φ0 ) cos B0 ],
*/
double[] centric = new double[dim];
double r = headerData.getRsun();
double b0 = headerData.getHglt();
double a0 = headerData.getHgln();
double crln = headerData.getCrln();
double L0 = 0.0;
if (!headerData.isStereo()) {
b0 = headerData.getL0B0()[1]; //-headerData.getL0B0()[1]. tested aia euvi
}
if (isCarrington) {
L0 = headerData.getL0();
cs[0] = cs[0] - L0; //change to stony
}
double z = (double) Math.sqrt(r * r - cs[0] * cs[0] - cs[1] * cs[1]);
double b0 = this.hglt;
double a0 = this.hgln;
double L0 = 0.0;
centric[0] = r* Math.cos(Math.toRadians( cs[1])) * Math.sin(Math.toRadians( cs[0]-a0));
centric[1] = r* ( Math.sin(Math.toRadians( cs[1])) *Math.cos(Math.toRadians(b0)) - Math.cos(Math.toRadians( cs[1]))*Math.cos(Math.toRadians(cs[0]-a0))*Math.sin(Math.toRadians(b0) ));
return centric;
}
public double[] helioprojectiveToHeliocentric(double[] cs) {
/* Equations used:
* z = D d cos θy cos θ x ,
* x = D ( PI/180) θ x, (approximate)
* y = D ( PI/180) θ y.
*/
double[] centric = new double[dim];
double dsun = headerData.getDsun();
double rsun = headerData.getRsun();
double q = dsun * Math.cos( Math.toRadians( cs[1])) * Math.cos( Math.toRadians( cs[0]));
double d = q*q - dsun*dsun + rsun*rsun;
// if (d<0)
// d = q - Math.sqrt(d);
centric[0] = (double) (d * Math.cos( Math.toRadians( cs[1])) * Math.sin( Math.toRadians( cs[0])));// /3600
centric[1] = (double) (d * Math.sin( Math.toRadians( cs[1])));
return centric;
}
public double[] heliocentricToHelioprojective(double[] cs) {
/* Equations used:
* d= x2 + y2 + (D z)2 ,
* θ x = arg(D z, x),
* θy = sin1 (y/d).
*/
double[] projective = new double[dim];
double d = headerData.getDsun();
double d0 = (double) Math.sqrt(d*d -cs[0]*cs[0] -cs[1]*cs[1]);
projective[0] = Math.atan(cs[0] / d0);
projective[1] = (double) Math.asin(cs[1] / d);
projective[0] = Math.toDegrees(projective[0]);
projective[1] = Math.toDegrees(projective[1]);
return projective;
}
if (!isStereo) {
b0 = this.B0;
}
public double[] heliographicToCylindrical(double[] cs, boolean isCarrington) {
/* Equations used:
* x = (n-n0) *cos Φ,
* y = Φ;
*/
double[] cylindrical = new double[dim];
double a0 = headerData.getHgln();
double crln = headerData.getCrln();
double L0 = 0.0;
if (isCarrington) {
L0 = this.L0;
}
if (isCarrington) {
L0 = headerData.getL0();
cs[0] = cs[0]; // - L0;
}
//System.out.println(" heliographicToHeliocentric() *** L0 = " +L0 +" crln = "+ crln+" b0 = "+ b0 + " B0 = " + headerData.getL0B0()[1]);
cylindrical[0] = cs[0]; //*cos Φ;r* Math.cos(Math.toRadians( cs[1])) * Math.sin(Math.toRadians( cs[0]-a0));
cylindrical[1] = cs[1]; //r* ( Math.sin(Math.toRadians( cs[1])) *Math.cos(Math.toRadians(b0)) - Math.cos(Math.toRadians( cs[1]))*Math.cos(Math.toRadians(cs[0]-a0))*Math.sin(Math.toRadians(b0) ));
return cylindrical;
}
public double[] heliocentricToCylindrical(double[] cs) {
/* Equations used:
* x = (n-n0) *cos Φ,
* y = Φ;
*/
double[] cylindrical = new double[dim];
double r = 0.0;
double theta = 0.0;
r = Math.sqrt(cs[0]*cs[0] + cs[1]*cs[1]);
theta = Math.atan2(cs[1],cs[0]) * 180.0/Math.PI;
cylindrical[0] = r; //*cos Φ;r* Math.cos(Math.toRadians( cs[1])) * Math.sin(Math.toRadians( cs[0]-a0));
cylindrical[1] = theta; //r* ( Math.sin(Math.toRadians( cs[1])) *Math.cos(Math.toRadians(b0)) - Math.cos(Math.toRadians( cs[1]))*Math.cos(Math.toRadians(cs[0]-a0))*Math.sin(Math.toRadians(b0) ));
return cylindrical;
}
double temp = (double) ((cs[1] * Math.cos(Math.toRadians(b0)) + z
* Math.sin(Math.toRadians(b0))) / r); // lat
helio[1] = (double) Math.asin(temp);
helio[1] = Math.toDegrees(helio[1]);
public HeaderData getHeaderData() {
return headerData;
}
temp = (double) ((cs[0]) / (z * Math.cos(Math.toRadians(b0)) - cs[1]
* Math.sin(Math.toRadians(b0))));
helio[0] = (double) (Math.toRadians(a0) + Math.atan(temp));
helio[0] = Math.toDegrees(helio[0]) + L0;
if (helio[0] < -180)
helio[0] = helio[0] + 360;
if (helio[0] > 180)
helio[0] = helio[0] - 360;
if (helio[0] < 0)
helio[0] = helio[0] + 360;
return helio;
}
public double[] heliographicToHeliocentric(double[] cs, boolean isCarrington) {
/*
* Equations used: centric[0] = r cos Θ sin(Φ Φ0 ), centric[1] = r[sin
* Θ cos B0 cos Θ cos(Φ Φ0 ) sin B0 ], z = r[sin Θ sin B0 + cos Θ
* cos(Φ Φ0 ) cos B0 ],
*/
double[] centric = new double[dim];
double r = this.rsun;
double b0 = this.hglt;
double a0 = this.hgln;
double L0 = 0.0;
if (!isStereo) {
b0 = this.B0; // -headerData.getL0B0()[1]. tested aia euvi
}
if (isCarrington) {
L0 = this.L0;
cs[0] = cs[0] - L0; // change to stony
}
centric[0] = r * Math.cos(Math.toRadians(cs[1]))
* Math.sin(Math.toRadians(cs[0] - a0));
centric[1] = r
* (Math.sin(Math.toRadians(cs[1]))
* Math.cos(Math.toRadians(b0)) - Math.cos(Math
.toRadians(cs[1]))
* Math.cos(Math.toRadians(cs[0] - a0))
* Math.sin(Math.toRadians(b0)));
return centric;
}
public double[] helioprojectiveToHeliocentric(double[] cs) {
/*
* Equations used: z = D d cos θy cos θ x , x = D ( PI/180) θ x,
* (approximate) y = D ( PI/180) θ y.
*/
double[] centric = new double[dim];
double dsun = this.dsun;
double rsun = this.rsun;
double q = dsun * Math.cos(Math.toRadians(cs[1]))
* Math.cos(Math.toRadians(cs[0]));
double d = q * q - dsun * dsun + rsun * rsun;
// if (d<0)
// d = q - Math.sqrt(d);
centric[0] = (double) (d * Math.cos(Math.toRadians(cs[1])) * Math
.sin(Math.toRadians(cs[0])));// /3600
centric[1] = (double) (d * Math.sin(Math.toRadians(cs[1])));
return centric;
}
public double[] heliocentricToHelioprojective(double[] cs) {
/*
* Equations used: d= x2 + y2 + (D z)2 , θ x = arg(D z, x), θy =
* sin1 (y/d).
*/
double[] projective = new double[dim];
double d = this.dsun;
double d0 = (double) Math.sqrt(d * d - cs[0] * cs[0] - cs[1] * cs[1]);
projective[0] = Math.atan(cs[0] / d0);
projective[1] = (double) Math.asin(cs[1] / d);
projective[0] = Math.toDegrees(projective[0]);
projective[1] = Math.toDegrees(projective[1]);
return projective;
}
public double[] heliographicToCylindrical(double[] cs, boolean isCarrington) {
/*
* Equations used: x = (n-n0) *cos Φ, y = Φ;
*/
double[] cylindrical = new double[dim];
if (isCarrington) {
cs[0] = cs[0]; // - L0;
}
// System.out.println(" heliographicToHeliocentric() *** L0 = " +L0
// +" crln = "+ crln+" b0 = "+ b0 + " B0 = " + headerData.getL0B0()[1]);
cylindrical[0] = cs[0]; // *cos Φ;r* Math.cos(Math.toRadians( cs[1])) *
// Math.sin(Math.toRadians( cs[0]-a0));
cylindrical[1] = cs[1]; // r* ( Math.sin(Math.toRadians( cs[1]))
// *Math.cos(Math.toRadians(b0)) -
// Math.cos(Math.toRadians(
// cs[1]))*Math.cos(Math.toRadians(cs[0]-a0))*Math.sin(Math.toRadians(b0)
// ));
return cylindrical;
}
public double[] heliocentricToCylindrical(double[] cs) {
/*
* Equations used: x = (n-n0) *cos Φ, y = Φ;
*/
double[] cylindrical = new double[dim];
double r = 0.0;
double theta = 0.0;
r = Math.sqrt(cs[0] * cs[0] + cs[1] * cs[1]);
theta = Math.atan2(cs[1], cs[0]) * 180.0 / Math.PI;
cylindrical[0] = r; // *cos Φ;r* Math.cos(Math.toRadians( cs[1])) *
// Math.sin(Math.toRadians( cs[0]-a0));
cylindrical[1] = theta; // r* ( Math.sin(Math.toRadians( cs[1]))
// *Math.cos(Math.toRadians(b0)) -
// Math.cos(Math.toRadians(
// cs[1]))*Math.cos(Math.toRadians(cs[0]-a0))*Math.sin(Math.toRadians(b0)
// ));
return cylindrical;
}
public int getDim() {
return dim;
}
public void setDim(int dim) {
this.dim = dim;
}
public double getRsun() {
return rsun;
}
public void setRsun(double rsun) {
this.rsun = rsun;
}
public double getDsun() {
return dsun;
}
public void setDsun(double dsun) {
this.dsun = dsun;
}
public double getHgln() {
return hgln;
}
public void setHgln(double hgln) {
this.hgln = hgln;
}
public double getHglt() {
return hglt;
}
public void setHglt(double hglt) {
this.hglt = hglt;
}
public double getCrln() {
return crln;
}
public void setCrln(double crln) {
this.crln = crln;
}
public double getB0() {
return B0;
}
public void setB0(double b0) {
B0 = b0;
}
public double getL0() {
return L0;
}
public void setL0(double l0) {
L0 = l0;
}
public boolean isStereo() {
return isStereo;
}
public void setStereo(boolean isStereo) {
this.isStereo = isStereo;
}
}

View file

@ -1,14 +1,7 @@
package gov.noaa.nws.ncep.viz.rsc.solarimage.wcs;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import nom.tam.fits.Header;
import nom.tam.fits.TruncatedFileException;
import nom.tam.util.BufferedDataInputStream;
/**
* Provides methods for fits wcs transformation.
* Provides methods for Cylindrical transformation.
*
* <pre>
*
@ -17,54 +10,50 @@ import nom.tam.util.BufferedDataInputStream;
* Date Ticket# Engineer Description
* ------------ ---------- ---------- --------------------------
*
* 04/04/2013 #958 q.zhou Initial creation
*
*
* 04/04/2013 #958 q.zhou Initial creation
*
*
* </pre>
*
* @author q.zhou
* @version 2
*/
public class CylindricalConverter {
//Convert pixel to real world coordinates
// Convert pixel to real world coordinates
/**
* @param
* @param
*/
public CylindricalConverter() {
}
public double[] imageToWorld(double[] image) {
// Convert pixel 0-360 to real world coordinates
double[] cs = new double[2];
if (cs[0] >= 0 && cs[0] <= 360 )
cs[0] = image[0] - 180;
// Convert pixel 0-360 to real world coordinates
double[] cs = new double[2];
if (cs[0] >= 0 && cs[0] <= 360)
cs[0] = image[0] - 180;
else
System.out.println("x is out of 0-360");
if (cs[1] >= 0 && cs[1] <= 180 )
cs[1] = image[1] - 90;
System.out.println("x is out of 0-360");
if (cs[1] >= 0 && cs[1] <= 180)
cs[1] = image[1] - 90;
else
System.out.println("y is out of 0-180");
System.out.println("y is out of 0-180");
return cs;
}
public double[] WorldToImage(double[] cs) {
double[] image = new double[2];
if (cs[0] >= -180 && cs[0] <= 180 )
image[0] = cs[0] + 180;
else
System.out.println("x is out of positive and negtive 180");
if (cs[1] >= -90 && cs[1] <= 90 )
image[1] = cs[1] + 90;
else
System.out.println("y is out of positive and negtive 90");
double[] image = new double[2];
if (cs[0] >= -180 && cs[0] <= 180)
image[0] = cs[0] + 180;
if (cs[1] >= -90 && cs[1] <= 90)
image[1] = cs[1] + 90;
return image;
}

View file

@ -19,7 +19,10 @@ import nom.tam.util.BufferedDataInputStream;
*
* 02/14/2013 #958 q.zhou Convert original fits to wcs format.
* Convert pixel to real world coordinates
*
* 11/17/2013 958 qzhou Added fixes for no flip image: modified pc, pcInv, crota and crpix.
* 01/07/2014 1046 qzhou Fixed imagefunction rotation problem. Added constructor for cylindrical.
* Fixed imageToWorld and worldToImage reverse problem.
* Added WorldToImageSamp method for sampling
* </pre>
*
* @author q.zhou
@ -27,10 +30,10 @@ import nom.tam.util.BufferedDataInputStream;
*/
public class WCSConverter {
private Header header;
private int dim = 0;
private double[] naxis;
private double[] crpix;
private double[] cdelt;
@ -38,39 +41,47 @@ public class WCSConverter {
private double[] crval;
private double[] crota;
private double a = 0.0;
private double[][] pc;
private double[][] cd;
private double[][] pcInv, cdInv;
//private double[][] m, mInv;
//private double[][] pv, pvInv;
private double[][] pcInv, cdInv;
private boolean containsPC = false;
private boolean containsCD = false;
private int cylindrical;
private boolean equalNavigation = false;
/**
* @param header
*/
public WCSConverter(Header header) {
this.header = header;
init();
public WCSConverter(Header header, int cylindrical) {
this.cylindrical = cylindrical;
if (header.getStringValue("TELESCOP").startsWith("NSO-GONG")
|| header.getStringValue("TELESCOP").startsWith("SDO/AIA"))
this.equalNavigation = true;
init(header);
}
public WCSConverter(byte[] data) throws TruncatedFileException,
IOException {
public WCSConverter(byte[] data) throws TruncatedFileException, IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(data);
BufferedDataInputStream stream = new BufferedDataInputStream(bis);
this.header = new Header(stream);
init();
init(new Header(stream));
}
/*
* Initialize and Convert original fits to wcs
* Initialize and Convert original fits to wcs
*/
private void init() {
dim = header.getIntValue("NAXIS");
private void init(Header header) {
dim = header.getIntValue("NAXIS");
naxis = new double[dim];
crpix = new double[dim];
cdelt = new double[dim];
crval = new double[dim];
@ -78,195 +89,183 @@ public class WCSConverter {
pc = new double[dim][dim];
cd = new double[dim][dim];
pcInv = new double[dim][dim];
cdInv = new double[dim][dim];
cdInv = new double[dim][dim];
containsPC = header.containsKey("PC1_1");
containsCD = header.containsKey("CD1_1");
for (int n = 0; n < dim; n++) {
String ij = Integer.toString(n + 1);
crpix[n] = header.getDoubleValue("CRPIX" + ij, 0.0); //if null, 0.0
crpix[n] = header.getDoubleValue("CRPIX" + ij, 0.0); // if null, 0.0
cdelt[n] = header.getDoubleValue("CDELT" + ij, 1.0);
crval[n] = header.getDoubleValue("CRVAL" + ij, 0.0);
crota[n] = header.getDoubleValue("CROTA" + ij, 0.0);
naxis[n] = header.getDoubleValue("NAXIS" + ij, 0.0);
}
for (int m = 0; m < dim; m++) {
String i = Integer.toString(m + 1);
for (int n = 0; n < dim; n++) {
String j = Integer.toString(n + 1);
pc[m][n] = header.getDoubleValue("PC" +i +"_" +j, 0.0);
cd[m][n] = header.getDoubleValue("CD" +i +"_" +j, 0.0);
pcInv[m][n] = pc[m][n];
cdInv[m][n] = cd[m][n];
}
String i = Integer.toString(m + 1);
for (int n = 0; n < dim; n++) {
String j = Integer.toString(n + 1);
pc[m][n] = header.getDoubleValue("PC" + i + "_" + j, 0.0);
cd[m][n] = header.getDoubleValue("CD" + i + "_" + j, 0.0);
pcInv[m][n] = pc[m][n];
cdInv[m][n] = cd[m][n];
}
}
// Convert original to pc. Do not convert original fits to cd.
if (!header.containsKey("PC1_1") && !header.containsKey("CD1_1")) {
if ( crota[1] != 0.0) //CROTA2
a = crota[1];
else if ( crota[0] != 0.0)
a = crota[0];
if (dim == 2 ) {
for (int i = 0; i < dim; i++) {
// change pc for no flip method up
pc[0][1] = -pc[0][1];
pc[1][0] = -pc[1][0];
// Convert original to pc. Do not convert original fits to cd.
if (!header.containsKey("PC1_1") && !header.containsKey("CD1_1")) {
double rota = 0.0;
if (crota[1] != 0.0) // CROTA2
rota = crota[1];
else if (crota[0] != 0.0)
rota = crota[0];
// change pc for no flip method
rota = -rota;
if (dim == 2) {
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
if (i == j) {
pc[i][j] = Math.cos(Math.toRadians( a));
pc[i][j] = Math.cos(Math.toRadians(rota));
} else if (i < j) {
pc[i][j] = (-Math.sin(Math.toRadians(rota)))
* cdelt[1] / cdelt[0];
} else if (i > j) {
pc[i][j] = (Math.sin(Math.toRadians(rota)))
* cdelt[0] / cdelt[1];
}
else if (i < j) {
pc[i][j] = (-Math.sin(Math.toRadians( a))) * cdelt[1]/cdelt[0];
}
else if (i > j) {
pc[i][j] = (Math.sin(Math.toRadians( a))) * cdelt[0]/cdelt[1];
}
}
}
}
}
// inverse
if (dim == 2 ) {
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
if (i == j) {
pcInv[i][j] = pc[i][j];
cdInv[i][j] = cd[i][j];
}
else {
pcInv[i][j] = -pc[i][j];
cdInv[i][j] = -cd[i][j];
}
}
}
}
//System.out.println("here "+ pc[0][0] +" "+pc[0][1]+" " +pcInv[0][0] +" "+pcInv[0][1]+" ");
// dim = header.getIntValue("NAXIS");
// crpix = new double[dim];
// cdelt = new double[dim];
// crval = new double[dim];
// crota = new double[dim];
// for (int n = 0; n < dim; n++) {
// String ij = Integer.toString(n + 1);
// crpix[n] = header.getDoubleValue("CRPIX" + ij, 0.0);
// cdelt[n] = header.getDoubleValue("CDELT" + ij, 1.0);
// crval[n] = header.getDoubleValue("CRVAL" + ij, 0.0);
// crota[n] = header.getDoubleValue("CROTA" + ij, 0.0);
// }
//
// /* Set up rotation matrix (and its inverse) */
// m = new double[dim][dim];
// mInv = new double[dim][dim];
// if (dim == 2 && header.containsKey("CROTA1")) {
// double sine = Math.sin(Math.toRadians(crota[0]));
// double cosine = Math.cos(Math.toRadians(crota[0]));
// m[0][0] = cosine;
// m[0][1] = -sine;
// m[1][0] = sine;
// m[1][1] = cosine;
// mInv[0][0] = cosine;
// mInv[0][1] = sine;
// mInv[1][0] = -sine;
// mInv[1][1] = cosine;
// } else {
// for (int i = 0; i < dim; i++) {
// for (int j = 0; j < dim; j++) {
// if (i == j)
// m[i][j] = 1.0;
// else
// m[i][j] = 0.0;
// }
// }
// mInv = m;
// }
// inverse
if (dim == 2) {
if (cylindrical == 0) {
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
if (i == j) {
pcInv[i][j] = pc[i][j];
cdInv[i][j] = cd[i][j];
} else {
pcInv[i][j] = -pc[i][j];
cdInv[i][j] = -cd[i][j];
}
}
}
} else {
pcInv = pc;
cdInv = cd;
}
}
}
public double[] imageToWorld(double[] image) {
double[] cs = new double[dim];
/*
* formula:
*
* double x= crval[0] +cdelt[0] *(pc[0][0]*cs[0] + pc[0][1]*cs[1]);
* double y= crval[1] +cdelt[1] *(pc[1][0]*cs[0] + pc[1][1]*cs[1]);
*/
double[] cs = new double[dim];
double[] tmp = new double[dim];
for (int j = 0; j < dim; j++) {
cs[j] = image[j] - crpix[j];
}
// double x = crval[0] + cdelt[0] * (pc[0][0] * cs[0] + pc[0][1] * cs[1]);
// double y = crval[1] + cdelt[1] * (pc[1][0] * cs[0] + pc[1][1] * cs[1]);
for (int i = 0; i < dim; i++) {
tmp[i] = 0.0;
for (int j = 0; j < dim; j++) {
if (dim == 2 && header.containsKey("PC1_1"))
tmp[i] += pc[i][j] * cs[j] * cdelt[i];
else if (dim == 2 && header.containsKey("CD1_1"))
tmp[i] += cd[i][j] * cs[j];
else
tmp[i] += pc[i][j] * cs[j] * cdelt[i];
}
}
/*
* Changed for no flip reading data. Was: for (int j = 0; j < dim; j++)
* cs[j] = image[j] - crpix[j];
*/
cs[0] = image[0] - crpix[0];
cs[1] = image[1] - (naxis[1] - crpix[1]);
for (int i = 0; i < dim; i++) {
cs[i] = tmp[i];
tmp[i] = 0.0;
for (int j = 0; j < dim; j++) {
if (dim == 2 && containsPC)
tmp[i] += pc[i][j] * cs[j] * cdelt[i];
else if (dim == 2 && containsCD)
tmp[i] += cd[i][j] * cs[j];
else
tmp[i] += pc[i][j] * cs[j] * cdelt[i];
}
}
for (int i = 0; i < dim; i++) {
cs[i] = tmp[i];
cs[i] += crval[i];
}
//System.out.println("***xy "+ x +" "+ y);
//System.out.println("***cs "+ cs[0] +" "+cs[1]);
return cs;
// double[] wcs = new double[dim];
// double[] tmp = new double[dim];
// for (int j = 0; j < dim; j++) {
// System.out.println("***imgOrig "+ image[0] +" "+image[1]);
// wcs[j] = image[j] - crpix[j];
// }
// for (int i = 0; i < dim; i++) {
// tmp[i] = 0.0;
// for (int j = 0; j < dim; j++) {
// tmp[i] += m[i][j] * wcs[j];
// }
// }
// for (int i = 0; i < dim; i++) {
// wcs[i] = cdelt[i] * tmp[i];
// wcs[i] += crval[i];
// }
// System.out.println("***wcs "+ wcs[0] +" "+wcs[1]);
// return wcs;
}
public double[] WorldToImage(double[] cs) {
double[] image = new double[dim];
double[] image = new double[dim];
double[] tmp = new double[dim];
for (int i = 0; i < dim; i++) {
image[i] = (cs[i] - crval[i]); // / cdelt[i];
image[i] = (cs[i] - crval[i]);
}
for (int i = 0; i < dim; i++) {
tmp[i] = 0.0;
for (int j = 0; j < dim; j++) {
if (dim == 2 && header.containsKey("PC1_1"))
tmp[i] += pcInv[i][j] * image[j] / cdelt[i];
else if (dim == 2 && header.containsKey("CD1_1"))
tmp[i] += cdInv[i][j] * image[j];
else
tmp[i] += pcInv[i][j] * image[j] / cdelt[i];
}
}
for (int j = 0; j < dim; j++) {
image[j] = tmp[j] + crpix[j];
for (int i = 0; i < dim; i++) {
tmp[i] = 0.0;
for (int j = 0; j < dim; j++) {
if (dim == 2 && containsPC)
tmp[i] += pcInv[i][j] * image[j] / cdelt[i];
else if (dim == 2 && containsCD)
tmp[i] += cdInv[i][j] * image[j];
else
tmp[i] += pcInv[i][j] * image[j] / cdelt[i];
}
}
// for (int i = 0; i < dim; i++) {
// tmp[i] = 0.0;
// for (int j = 0; j < dim; j++) {
// tmp[i] += mInv[i][j] * image[j];
// }
// }
// for (int j = 0; j < dim; j++) {
// image[j] = tmp[j] + crpix[j];
// }
//System.out.println("******image "+ image[0] +" "+image[1]);
if (cylindrical != 0) {
for (int j = 0; j < dim; j++) {
image[j] = tmp[j] + crpix[j];
}
} else {
image[0] = tmp[0] + crpix[0];
image[1] = tmp[1] + (naxis[1] - crpix[1]);
}
return image;
}
public double[] WorldToImageSamp(double[] cs) {
double[] image = new double[dim];
double[] tmp = new double[dim];
for (int i = 0; i < dim; i++) {
image[i] = (cs[i] - crval[i]);
}
for (int i = 0; i < dim; i++) {
tmp[i] = 0.0;
for (int j = 0; j < dim; j++) {
if (dim == 2 && containsPC)
tmp[i] += pc[i][j] * image[j] / cdelt[i];
else if (dim == 2 && containsCD)
tmp[i] += cd[i][j] * image[j];
else
tmp[i] += pc[i][j] * image[j] / cdelt[i];
}
}
for (int j = 0; j < dim; j++) {
image[j] = tmp[j] + crpix[j];
}
return image;
}
public boolean hasEqualNavigation() {
return equalNavigation;
}
}