12.4.1-7 baseline

Former-commit-id: 6d585942fe [formerly 90ae4bbb36] [formerly cca73b3c62 [formerly 3524730cc38b5420e7529b5a75d62313695e64d6]]
Former-commit-id: cca73b3c62
Former-commit-id: d9f966008c
This commit is contained in:
Steve Harris 2012-04-24 15:24:39 -05:00
parent a2a6a18fae
commit 4c88c0ae6c
333 changed files with 24698 additions and 13213 deletions

View file

@ -94,7 +94,7 @@ public class MdlSndNSharpResourceData extends D2DNSharpResourceData {
@Override
protected NcSoundingCube getSoundingCube(NsharpStationInfo stnInfo) {
float[][] latLon = { { stnInfo.getLatitude(), stnInfo.getLongitude() } };
double[][] latLon = { { stnInfo.getLatitude(), stnInfo.getLongitude() } };
return NcSoundingQuery.pfcSoundingQueryByLatLon(stnInfo.getReftime()
.getTime(), stnInfo.getRangestarttime().getTime(), latLon,
stnInfo.getSndType(), NcSoundingLayer.DataType.ALLDATA, false,

View file

@ -21,6 +21,8 @@ package com.raytheon.viz.gfe;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@ -31,6 +33,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.gfe.dialogs.GFEConfigDialog;
import com.raytheon.viz.gfe.procedures.ProcedureJob;
import com.raytheon.viz.gfe.smarttool.script.SmartToolJob;
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
/**
* The activator class controls the plug-in life cycle
@ -99,30 +103,49 @@ public class Activator extends AbstractUIPlugin implements BundleActivator {
*/
@Override
public PythonPreferenceStore getPreferenceStore() {
synchronized (this) {
if (pythonPrefs == null) {
if (cfgDlg == null) {
cfgDlg = new GFEConfigDialog(
new Shell(Display.getDefault()));
}
cfgDlg.setBlockOnOpen(true);
cfgDlg.open();
String config = cfgDlg.getConfig();
// this is necessary because we sometimes get in here
// recursively and only want to do this once
if (pythonPrefs == null) {
pythonPrefs = new PythonPreferenceStore(config);
statusHandler.handle(Priority.EVENTA,
"GFE started with configuration: " + config);
}
}
}
return pythonPrefs;
}
public void setPreferenceStore(PythonPreferenceStore prefs) {
this.pythonPrefs = prefs;
}
public void createInitPreferenceStore() {
/*
* Check if GFE perspective is opened
*/
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
VizPerspectiveListener listener = VizPerspectiveListener
.getInstance(window);
if (listener != null) {
AbstractVizPerspectiveManager manager = listener
.getPerspectiveManager("com.raytheon.viz.ui.GFEPerspective");
if (manager == null || !manager.isOpened()) {
pythonPrefs = null;
}
}
/*
* If GFE is not opened, pop up the config dialog.
*/
synchronized (this) {
if (pythonPrefs == null) {
cfgDlg = new GFEConfigDialog(
new Shell(Display.getDefault()));
cfgDlg.setBlockOnOpen(true);
cfgDlg.open();
String config = cfgDlg.getConfig();
pythonPrefs = new PythonPreferenceStore(config);
statusHandler.handle(Priority.EVENTA,
"GFE started with configuration: " + config);
}
}
}
}

View file

@ -37,6 +37,7 @@ import com.raytheon.viz.gfe.Activator;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 7/1/06 chammack Initial Creation.
* 3/21/12 12469 mli Init PreferenceStore
*
* </pre>
*
@ -56,6 +57,7 @@ public class GFEPerspective implements IPerspectiveFactory {
* .IPageLayout)
*/
public void createInitialLayout(IPageLayout layout) {
Activator.getDefault().createInitPreferenceStore();
IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
// Get the editor area.

View file

@ -56,6 +56,7 @@ public class IdftRecord extends PluginDataObject{
/** Report type */
@Column(length=32)
@XmlElement
@DataURI(position = 4)
@DynamicSerializeElement
private String reportType;

View file

@ -134,4 +134,8 @@ INSERT INTO awips.mcidas_image_type VALUES (172, 'IR2', '2', '184');
INSERT INTO awips.mcidas_image_type VALUES (173, 'WV', '4', '184');
INSERT INTO awips.mcidas_image_type VALUES (174, 'IR', '8', '184');
INSERT INTO awips.mcidas_image_type VALUES (175, 'IR3', '128', '184');
INSERT INTO awips.mcidas_image_type VALUES (176, 'IR4', '16', '184');
INSERT INTO awips.mcidas_image_type VALUES (176, 'IR4', '16', '184');
INSERT INTO awips.mcidas_image_type VALUES (177, 'CAPE', '8', '185');
INSERT INTO awips.mcidas_image_type VALUES (178, 'CINH', '16', '185');
INSERT INTO awips.mcidas_image_type VALUES (179, 'LI', '32', '185');
INSERT INTO awips.mcidas_image_type VALUES (180, 'TPW', '64', '185');

View file

@ -27,3 +27,4 @@ INSERT INTO awips.mcidas_satellite_names VALUES (84,'MTS');
INSERT INTO awips.mcidas_satellite_names VALUES (85,'MTSAT2');
INSERT INTO awips.mcidas_satellite_names VALUES (180,'GOES13');
INSERT INTO awips.mcidas_satellite_names VALUES (184,'GOES15');
INSERT INTO awips.mcidas_satellite_names VALUES (185,'DPD');

View file

@ -63,7 +63,8 @@ import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
* 1/31/11 M. Li Add eventName for dynamic model name
* 9/08/11 X. Guo Check file size to create hash code
* 11/17/11 X. Guo Fixed hash generator problem
*
* 3/2012 T. Lee Added grib file template
*
* </pre>
*
* @author bphillip
@ -109,9 +110,13 @@ public class NcgribModel extends PersistableDataObject {
@XmlAttribute
@DynamicSerializeElement
private int genprocess;
@Column
@XmlAttribute
@DynamicSerializeElement
private String template;
/** The backgenprocess number (currently gfs is 0)
* ???
*/
@Column
@XmlAttribute
@ -173,7 +178,7 @@ public class NcgribModel extends PersistableDataObject {
@XmlAttribute
@DynamicSerializeElement
@DataURI(position = 4)
private Integer perturbationNumber;
private String perturbationNumber;
/** The number of forecasts in the ensemble */
@Column
@ -235,6 +240,7 @@ public class NcgribModel extends PersistableDataObject {
this.backGenprocess = copy.backGenprocess;
this.centerid = copy.centerid;
this.genprocess = copy.genprocess;
this.template = copy.template;
this.gridid = copy.gridid;
this.gridNumber = copy.gridNumber;
this.id = copy.id;
@ -270,6 +276,8 @@ public class NcgribModel extends PersistableDataObject {
.append("\n");
buffer.append(" Generating Process: ").append(genprocess).append(
"\n");
buffer.append(" Grib File Template: ").append(template).append(
"\n");
buffer.append(" Parameter Name: ").append(parameterName).append(
"\n");
buffer.append("Parameter Abbreviation: ").append(parameterAbbreviation)
@ -484,6 +492,25 @@ public class NcgribModel extends PersistableDataObject {
return genprocess;
}
/**
* Sets the file template
*
* @param fileTemplate
* The fileTemplate
*/
public void setTemplate(String template) {
this.template = template;
}
/**
* Gets the file template
*
* @return The fileTemplate
*/
public String getTemplate() {
return template;
}
/**
* Sets the genproces
*
@ -493,7 +520,7 @@ public class NcgribModel extends PersistableDataObject {
public void setGenprocess(int genprocess) {
this.genprocess = genprocess;
}
/**
* Gets the parameter name
*
@ -721,7 +748,7 @@ public class NcgribModel extends PersistableDataObject {
*
* @return The perturbation number
*/
public Integer getPerturbationNumber() {
public String getPerturbationNumber() {
return perturbationNumber;
}
@ -731,7 +758,7 @@ public class NcgribModel extends PersistableDataObject {
* @param perturbationNumber
* The perturbation number
*/
public void setPerturbationNumber(Integer perturbationNumber) {
public void setPerturbationNumber(String perturbationNumber) {
this.perturbationNumber = perturbationNumber;
}

View file

@ -36,9 +36,10 @@ import com.raytheon.uf.common.dataplugin.persist.IPersistable;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/24/09 1994 bphillip Initial Creation
* 1/12/12 xguo Create new HDF5 file name
* yyyy-MM-dd-HH-fhrs-ensNumber.h5
* 4/24/09 1994 bphillip Initial Creation
* 1/12/12 xguo Create new HDF5 file name
* yyyy-MM-dd-HH-fhrs-ensNumber.h5
* 3/2012 T. Lee changed pN to String
*
* </pre>
*
@ -109,13 +110,13 @@ public class NcgribPathProvider extends DefaultPathProvider {
synchronized (gribHdf5FileNameFormat) {
refTimeString = gribHdf5FileNameFormat.format(refTime);
}
int pbNum = 0;
String pbNum = "0";
if ( pdo.getModelInfo().getPerturbationNumber() != null){
pbNum = pdo.getModelInfo().getPerturbationNumber();
}
sb.append(refTimeString);
sb.append(String.format("-%d", fhrs));
sb.append(String.format("-%d", pbNum));
sb.append(String.format("-%s", pbNum));
sb.append(".h5");
return sb.toString();
}

View file

@ -64,6 +64,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
* 10/13/10 276 llin Modified for NC GRIB.
* 03/07/12 606 ghull Added eventName to URI for NcInventory updating.
*
* </pre>
*
@ -205,6 +206,7 @@ public class NcgribRecord extends PersistablePluginDataObject implements
@Column
@XmlAttribute
@DynamicSerializeElement
@DataURI(position = 8)
private String eventName;
/** Type of Generating Process

View file

@ -36,6 +36,7 @@ import com.raytheon.uf.common.time.DataTime;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 12, 2010 brockwoo Initial creation
* 3/2012 T. Lee Changed perturbation number to String
*
* </pre>
*
@ -69,7 +70,7 @@ public class NcgridDataRequestMessage implements IServerRequest {
private String parameterAbbreviation;
@DynamicSerializeElement
private int pert = -999;
private String pert = "";
@DynamicSerializeElement
private int version = -999;
@ -130,11 +131,11 @@ public class NcgridDataRequestMessage implements IServerRequest {
this.parameterAbbreviation = parameterAbbreviation;
}
public int getPert() {
public String getPert() {
return pert;
}
public void setPert(int pert) {
public void setPert(String pert) {
this.pert = pert;
}

View file

@ -20,6 +20,9 @@
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
@ -39,9 +42,6 @@ import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.opengis.referencing.operation.MathTransform;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@ -74,7 +74,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class LatLonNcgridCoverage extends NcgridCoverage {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(LatLonNcgridCoverage.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LatLonNcgridCoverage.class);
private static final long serialVersionUID = 8371251040172233074L;
@ -155,14 +156,13 @@ public class LatLonNcgridCoverage extends NcgridCoverage {
@Override
public void initialize() throws GribException {
double maxLon;
double maxLon;
double minLat = MapUtil.correctLat(la1);
double maxLat = MapUtil.correctLat(la2);
double minLon = MapUtil.correctLon(lo1);
if ( lo2 >= 360.0) {
maxLon = lo2;
}
else {
if (lo2 >= 360.0) {
maxLon = lo2;
} else {
maxLon = MapUtil.correctLon(lo2);
}
if (maxLon < minLon) {
@ -177,7 +177,10 @@ public class LatLonNcgridCoverage extends NcgridCoverage {
}
crsWKT = crs.toWKT();
try {
geometry = MapUtil.createGeometry(minLat, minLon, maxLat, maxLon);
double xOffset = dx * 0.5;
double yOffset = dy * 0.5;
geometry = MapUtil.createGeometry(minLat + yOffset, minLon
- xOffset, maxLat - yOffset, maxLon + xOffset);
} catch (Exception e) {
throw new GribException("Error creating geometry", e);
}
@ -187,13 +190,13 @@ public class LatLonNcgridCoverage extends NcgridCoverage {
@Override
public void generateName() {
String nameModel_gridid = "" + (int)(la1*10.) + (int) ((lo1 + la2+lo2)*100.);
String nameAndDescription = "Unknown LatLon " + nx + " X " + ny + " "
+ nameModel_gridid + " "
+ getProjectionType() + " grid";
//System.out.println(" nameModel_gridid=" + nameModel_gridid);
String nameModel_gridid = "" + (int) (la1 * 10.)
+ (int) ((lo1 + la2 + lo2) * 100.);
String nameAndDescription = "Unknown LatLon " + nx + " X " + ny + " "
+ nameModel_gridid + " " + getProjectionType() + " grid";
// System.out.println(" nameModel_gridid=" + nameModel_gridid);
this.setName(nameModel_gridid);
//this.setName(nameAndDescription);
// this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@ -283,8 +286,8 @@ public class LatLonNcgridCoverage extends NcgridCoverage {
}
rval.setId(rval.hashCode());
} else {
statusHandler.handle(
Priority.PROBLEM,
statusHandler
.handle(Priority.PROBLEM,
"Error creating sub grid definition ["
+ subGrid.getModelName()
+ "], units are not compatible with meter ["

View file

@ -20,6 +20,9 @@
package gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
@ -36,9 +39,6 @@ import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.opengis.referencing.operation.MathTransform;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@ -70,7 +70,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class MercatorNcgridCoverage extends NcgridCoverage {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(MercatorNcgridCoverage.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(MercatorNcgridCoverage.class);
private static final long serialVersionUID = 3140441023975157052L;
@ -179,7 +180,18 @@ public class MercatorNcgridCoverage extends NcgridCoverage {
crs = MapUtil.constructMercator(majorAxis, minorAxis, latin, meridian);
crsWKT = crs.toWKT();
try {
geometry = MapUtil.createGeometry(la1, lo1, la2, lo2);
// geometry = MapUtil.createGeometry(la1, lo1, la2, lo2);
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
if (spacingUnitObj.isCompatible(SI.METRE)) {
UnitConverter converter = spacingUnitObj
.getConverterTo(SI.METRE);
geometry = MapUtil.createGeometry(crs, la1, lo1,
converter.convert(dx), converter.convert(dy), nx, ny);
} else {
throw new GribException("Unable to convert " + spacingUnit
+ " to meters while creating geometry!");
}
} catch (Exception e) {
throw new GribException("Error creating geometry", e);
}
@ -192,9 +204,10 @@ public class MercatorNcgridCoverage extends NcgridCoverage {
String nameAndDescription = "Unknown Mercator " + nx + " X " + ny + " "
+ Math.round(dx) + " " + spacingUnit + " "
+ getProjectionType() + " grid";
String nameModel_gridid = "" + nx + ny + Integer.toString((int) (la1+la2+lo1+lo2));
String nameModel_gridid = "" + nx + ny
+ Integer.toString((int) (la1 + la2 + lo1 + lo2));
this.setName(nameModel_gridid);
//this.setName(nameAndDescription);
// this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@ -257,7 +270,8 @@ public class MercatorNcgridCoverage extends NcgridCoverage {
}
rval.setId(rval.hashCode());
} else {
statusHandler.handle(Priority.PROBLEM,
statusHandler.handle(
Priority.PROBLEM,
"Error creating sub grid definition ["
+ subGrid.getModelName()
+ "], units are not compatible with meter ["

View file

@ -28,6 +28,19 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* NcgridModel
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 3/12 T. Lee Initialized template
* </pre>
*
* @author njensen
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class NcgridModel implements ISerializableObject {
@ -55,6 +68,9 @@ public class NcgridModel implements ISerializableObject {
@XmlElement(name = "id")
private ArrayList<Integer> process;
@XmlElement
private String template = "NONE";
@XmlElement
private String alias;
@ -111,6 +127,14 @@ public class NcgridModel implements ISerializableObject {
public void setSubCenter(String subcenter) {
this.subcenter = subcenter;
}
public String getTemplate() {
return this.template;
}
public void setTemplate(String template) {
this.template = template;
}
public void setAlias(String alias) {
this.alias = alias;

View file

@ -78,6 +78,8 @@ import com.raytheon.uf.common.time.DataTime;
* IPointData -- that is, presents a PointDataView
* object suitable for HDF5 persistence.
* 10 Oct 2011 126 G. Hull replace stnid,lat&lon with the SurfaceObsLocation.
* 03 Feb 2012 606 G. Hull added reportType to the URI for inventory updating
*
* </pre>
*
* @author B. Hebbard, SIB
@ -97,6 +99,7 @@ public class NcPafmRecord extends PluginDataObject implements
/** Report type */
@Column(length=32)
@DataURI(position=6)
@XmlElement
@DynamicSerializeElement
private String reportType;

View file

@ -56,14 +56,13 @@ public class WcpRecord extends PluginDataObject{
/** Report type */
@Column(length=32)
@DynamicSerializeElement
@DataURI(position = 2)
private String reportType;
//@DataURI(position = 1)
@Column
@DynamicSerializeElement
private Calendar issueTime;
//@DataURI(position = 2)
@DataURI(position = 1)
@Column(length = 8)
@DynamicSerializeElement

View file

@ -29,6 +29,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
private static final long serialVersionUID = 5545342242369880295L;
public IceType(){
super( UNIT );
}
super( UNIT );
setValueIsString();
}
}

View file

@ -137,6 +137,7 @@ public class MetParameterFactory implements ISerializableObject{
ncParamsMap.put( HighResWaveHeight.class.getSimpleName(), new HighResWaveHeight() );
ncParamsMap.put( HumitureIndex.class.getSimpleName(), new HumitureIndex() );
ncParamsMap.put( IceCode.class.getSimpleName(), new IceCode() );
ncParamsMap.put( IceType.class.getSimpleName(), new IceType() );
ncParamsMap.put( IcingIntensitySymbol.class.getSimpleName(), new IcingIntensitySymbol() );
ncParamsMap.put( IcingTypeSymbol.class.getSimpleName(), new IcingTypeSymbol() );
ncParamsMap.put( InterWindDir.class.getSimpleName(), new InterWindDir() );
@ -270,6 +271,7 @@ public class MetParameterFactory implements ISerializableObject{
ncParamsMap.put( TotalSkyCoverFcst12hr.class.getSimpleName(), new TotalSkyCoverFcst12hr() );
ncParamsMap.put( TurbulenceFrequencySymbol.class.getSimpleName(), new TurbulenceFrequencySymbol() );
ncParamsMap.put( TurbulenceIntensitySymbol.class.getSimpleName(), new TurbulenceIntensitySymbol() );
ncParamsMap.put( TurbulenceTypeSymbol.class.getSimpleName(), new TurbulenceTypeSymbol() );
ncParamsMap.put( TurbulentKineticEnergy.class.getSimpleName(), new TurbulentKineticEnergy() );
ncParamsMap.put( EstStormDirectionUComp.class.getSimpleName(), new EstStormDirectionUComp() );
ncParamsMap.put( UCompAt10Meters.class.getSimpleName(), new UCompAt10Meters() );

View file

@ -0,0 +1,35 @@
/**
*
*/
package gov.noaa.nws.ncep.edex.common.metparameters;
import javax.measure.quantity.Dimensionless;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
* Maps to the GEMPAK parameter TPOT
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class TurbulenceTypeSymbol extends AbstractMetParameter implements
Dimensionless, ISerializableObject {
/**
*
*/
private static final long serialVersionUID = -6287889028169403542L;
public TurbulenceTypeSymbol() {
super(UNIT);
setValueIsString();
}
}

View file

@ -17,6 +17,7 @@ package gov.noaa.nws.ncep.edex.common.sounding;
* 12/16/2010 362 Chin Chen add support of BUFRUA observed sounding and PFC (NAM and GFS) model sounding data
* 09/14/2011 457 S. Gurung Renamed ObsSndType.H5UAIR to ObsSndType.NCUAIR
*10/06/2011 465 Archana Added a list of NcSoundingLayer2 objects to the sounding profile
* 02/15/2012 Chin Chen added fcsTime to support pfc sounding query
* </pre>
*
* @author Chin Chen
@ -74,9 +75,9 @@ public class NcSoundingProfile implements ISerializableObject{
//@DynamicSerializeElement
//private String stationId;
@DynamicSerializeElement
private float stationLatitude;
private double stationLatitude;
@DynamicSerializeElement
private float stationLongitude;
private double stationLongitude;
@DynamicSerializeElement
private float sfcPress;
@ -85,6 +86,9 @@ public class NcSoundingProfile implements ISerializableObject{
@DynamicSerializeElement
private int stationNum;
@DynamicSerializeElement
private long fcsTime;
@DynamicSerializeElement
private NcSoundingCube.QueryStatus rtnStatus = NcSoundingCube.QueryStatus.OK;
@ -114,6 +118,15 @@ public class NcSoundingProfile implements ISerializableObject{
this.stationNum = stnNum;
}
public long getFcsTime() {
return fcsTime;
}
public void setFcsTime(long fcsTime) {
this.fcsTime = fcsTime;
}
public List<NcSoundingLayer> getSoundingLyLst() {
return soundingLyLst;
}
@ -145,19 +158,19 @@ public class NcSoundingProfile implements ISerializableObject{
}
public float getStationLatitude() {
public double getStationLatitude() {
return stationLatitude;
}
public void setStationLatitude(float stationLatitude) {
public void setStationLatitude(double stationLatitude) {
this.stationLatitude = stationLatitude;
}
public float getStationLongitude() {
public double getStationLongitude() {
return stationLongitude;
}
public void setStationLongitude(float stationLongitude) {
public void setStationLongitude(double stationLongitude) {
this.stationLongitude = stationLongitude;
}

View file

@ -41,9 +41,11 @@ public class NcSoundingStnInfo implements ISerializableObject{
@DynamicSerializeElement
private float stationElevation;
@DynamicSerializeElement
private float stationLatitude;
//private float stationLatitude;
private double stationLatitude;
@DynamicSerializeElement
private float stationLongitude;
//private float stationLongitude;
private double stationLongitude;
@DynamicSerializeElement
private String stnId;
@DynamicSerializeElement
@ -67,16 +69,16 @@ public class NcSoundingStnInfo implements ISerializableObject{
public void setStationElevation(float stationElevation) {
this.stationElevation = stationElevation;
}
public float getStationLatitude() {
public double getStationLatitude() {
return stationLatitude;
}
public void setStationLatitude(float stationLatitude) {
public void setStationLatitude(double stationLatitude) {
this.stationLatitude = stationLatitude;
}
public float getStationLongitude() {
public double getStationLongitude() {
return stationLongitude;
}
public void setStationLongitude(float stationLongitude) {
public void setStationLongitude(double stationLongitude) {
this.stationLongitude = stationLongitude;
}
public String getStnId() {

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestPatterns xmlns:ns2="group">
<regex>^MANUAL INGEST.*</regex>
<regex>^MCIDAS.*</regex>
<!-- <regex>^MANUAL INGEST.*</regex> -->
</requestPatterns>

View file

@ -0,0 +1 @@
gov.noaa.nws.ncep.common.dataplugin.ncairep.NcAirepRecord

View file

@ -46,6 +46,7 @@ import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
* 10/04/2011 286 Q.Zhou Removed wmoHeader parameter. Modified splitLatLon() to solve 3606S 15942E
* 10/17/2011 286 Q.Zhou Added WX_COND_WORDS and checking.
* 11/01/2011 286 Q.Zhou Added month and year to decodetime
* 02/15/2012 Q.Zhou Added in decodeHazard() to ice type for possible icing type input
* </pre>
*/
public class NcAirepParser
@ -846,14 +847,40 @@ public class NcAirepParser
if ( !theElements.get(iIc).toString().equalsIgnoreCase("RM")
&& !theElements.get(iIc).toString().equalsIgnoreCase("SK")) { //didn't see, in case...
iceInten = theElements.get(iIc).toString();
if (WX_COND_WORDS.get(iceInten) != null)
iceInten = WX_COND_WORDS.get(iceInten);
// handle iceInten number value
iceInten = checkIceNumAirep(iceInten);
String temp = theElements.get(iIc).toString();
if (WX_COND_WORDS.get(temp) != null)
temp = WX_COND_WORDS.get(temp);
if (temp.startsWith("RIM") || temp.startsWith("CL") || temp.startsWith("MX"))
iceType = temp;
else
iceInten = temp;
iIc++;
}
}
if (iIc !=0 && iIc < size) {
if ( !theElements.get(iIc).toString().equalsIgnoreCase("RM")
&& !theElements.get(iIc).toString().equalsIgnoreCase("SK")) { //didn't see, in case...
String temp = theElements.get(iIc).toString();
if (WX_COND_WORDS.get(temp) != null)
temp = WX_COND_WORDS.get(temp);
if (temp.startsWith("RIM") || temp.startsWith("CL") || temp.startsWith("MX"))
iceType = temp;
iIc++;
}
}
// handle iceInten number value
if (iIc !=0 && iceInten != null)
iceInten = checkIceNumAirep(iceInten);
// Airep: handle iceInten with "-". e.g. LGT-MOD => LGTMOD
if (iIc !=0 ) {
String[] s = iceInten.split("-");

View file

@ -1,3 +1,5 @@
gov.noaa.nws.ncep.edex.util.ncgrib.NcgridLevels
gov.noaa.nws.ncep.edex.util.ncgrib.Ncgrib1TableMap
gov.noaa.nws.ncep.edex.util.ncgrib.NccompositeModel
gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1Vcrd
gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1VcrdList

View file

@ -701,8 +701,26 @@ class NcgribDecoder():
# Special case handling for specific PDS Templates
if pdsTemplateNumber == 1 or pdsTemplateNumber == 11:
model.setTypeEnsemble(Integer(pdsTemplate[15]))
model.setPerturbationNumber(Integer(pdsTemplate[16]))
pdst15 = pdsTemplate[15]
model.setTypeEnsemble(Integer(pdst15))
# Use the following codes with correct grib headers
# print "Type of Ensemble Forecast: ", pdst15, " perturbation number: ", pdsTemplate[16]
#if ( pdst15 == 0 or self.fileName.find ('ctl1') != -1 ):
# self.derived = 'ctl1'
#elif ( pdst15 == 1 or self.fileName.find ('ctl2') != -1 ):
# self.derived = 'ctl2'
#elif pdst15 == 2:
# self.derived = 'n'
# to do
#elif pdst15 == 3:
# self.derived = 'p'
# To do
# set perturbation number when code value = 2/3/192 to avoid 0
if pdst15 == 2 or pdst15 == 3 or pdst15 == 192:
model.setPerturbationNumber(str(pdsTemplate[16]))
model.setNumForecasts(Integer(pdsTemplate[17]))
if pdsTemplateNumber == 11:
@ -716,14 +734,25 @@ class NcgribDecoder():
derivedForecast = pdsTemplate[15]
if (derivedForecast == 0 or derivedForecast == 1 or derivedForecast == 6):
parameterAbbreviation= parameterAbbreviation+"mean"
# parameterAbbreviation= parameterAbbreviation+"mean"
self.derived = 'mean'
elif (derivedForecast >= 2 and derivedForecast <= 5 ):
parameterAbbreviation= parameterAbbreviation+"sprd"
elif (derivedForecast == 2 or derivedForecast == 3 ):
# parameterAbbreviation= parameterAbbreviation+"sprd"
self.derived = 'sprd'
elif (derivedForecast >= 193 and derivedForecast <= 195 ):
parameterAbbreviation= parameterAbbreviation+"prob"
# parameterAbbreviation= parameterAbbreviation+"prob"
self.derived = 'prob'
# Use the following codes with correct grib headers
# if (derivedForecast >= 192 and derivedForecast <= 195 ):
#if ( derivedForecast == 193 or self.fileName.find ('10p') != -1):
# self.derived = '10p'
#elif ( derivedForecast == 194 or self.fileName.find ('50p') != -1):
# self.derived = '50p'
#elif ( derivedForecast == 195 or self.fileName.find ('90p') != -1):
# self.derived = '90p'
#elif ( derivedForecast == 192 or self.fileName.find ('mode') != -1):
# self.derived = 'mode'
model.setTypeEnsemble(Integer(pdsTemplate[15]))
model.setNumForecasts(Integer(pdsTemplate[16]))
@ -1412,7 +1441,7 @@ class NcgribDecoder():
gridid = model.getGridid()
process = model.getGenprocess()
gridModel = NcgribModelLookup.getInstance().getModel(center, subcenter, gridid, process)
gridModel = NcgribModelLookup.getInstance().getModel(center, subcenter, gridid, process, fileName, model)
if gridModel is None:
name = "NewGrid:" + str(center) + ":" + str(subcenter) + ":" + str(process) + ":" + gridid
@ -1420,33 +1449,31 @@ class NcgribDecoder():
hurricane = tokens[0]
basin = hurricane[-1]
trackno = hurricane[-3:-1]
if trackno.isdigit() or tokens[2] =="firewxnest":
if trackno.isdigit() or tokens[2] =="firewxnest" or tokens[2] == "hysplit":
if trackno.isdigit():
basins = "lewcs"
if basin in basins:
#name = "GHM:" + str(center) + ":" + str(subcenter) + ":" + str(process) + ":" + gridid
#hurricaneName = hurricane[:len(hurricane)-3]
name = "GHM"
name = "ghm"
if tokens[2] == "gribn3":
name = "GHMNEST"
name = "ghmNest"
elif tokens[2] == "grib6th":
name = "GHM6TH"
name = "ghm6th"
elif tokens[2] == "hwrfprs_n":
name = "HWRFNEST"
name = "hwrfNest"
elif tokens[2] == "hwrfprs_p":
name = "HWRF"
else:
name = "NAMFIREWX"
name = "hwrf"
elif tokens[2] == "firewxnest":
name = "fireWxNest"
else:
name = "hysplit"
NcgribModelLookup.getInstance().setModel(center, subcenter, gridid, process, name)
gridModel = NcgribModelLookup.getInstance().getModel(center, subcenter, gridid, process)
gridModel = NcgribModelLookup.getInstance().getModel(center, subcenter, gridid, process, filename)
#name = gridModel.getName()
else:
name = gridModel.getName()
if name == "GEFS" :
tokens = fileName.split(".")
gefc = tokens[0]
if gefc[:3] == "gec":
name = "GEFC"
model.setModelName(name)
@ -1527,18 +1554,35 @@ class NcgribDecoder():
if g2varsId > 0 :
parm = Grib2VarsTableLookup.getVarGnam(discipline, category, parameterId, pdt)
modelName = record.getModelName()
if self.derived == 'mean':
parm = parm + "ENMW"
if modelName.find('MEAN') == -1:
modelName = modelName +"MEAN"
elif self.derived == 'sprd':
parm = parm + "ENSA"
if modelName.find('SPREAD') == -1 :
modelName = modelName +"SPREAD"
elif self.derived == 'prob':
parm = parm + "PROB"
if modelName.find ('PROB') == -1:
modelName = modelName +"PROB"
#if self.derived == 'mean':
# parm = parm + "ENMW"
# if modelName.find('Mean') == -1:
# modelName = modelName +"Mean"
#if self.derived == 'sprd':
# parm = parm + "ENSA"
# if modelName.find('Spread') == -1 :
# modelName = modelName +"Spread"
#elif self.derived == 'prob':
# if modelName.find('PROB') == -1 :
# modelName = modelName +"PROB"
#elif self.derived == 'mode':
#parm = parm + "ENMO"
# if modelName.find('MODE') == -1 :
# modelName = modelName +"MODE"
#elif self.derived == '10p':
# parm = parm + "PROB"
# if modelName.find ('10P') == -1:
# modelName = modelName +"10P"
#elif self.derived == '50p':
# if modelName.find ('50P') == -1:
# modelName = modelName + "50P"
#elif self.derived == '90p':
# if modelName.find ('90P') == -1:
# modelName = modelName + "90P"
#elif self.derived == 'ctl1' or self.derived == 'ctl2':
# if modelName.find ('CTL') == -1:
# modelName = modelName + self.derived
record.setModelName(modelName)
record.getModelInfo().setModelName(modelName)

View file

@ -62,9 +62,9 @@ import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.MercatorNc
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.PolarStereoNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2VcrdTableLookup;
import gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1Vcrd;
import gov.noaa.nws.ncep.edex.util.grib1vcrd.Grib1VcrdTable;
import gov.noaa.nws.ncep.edex.util.grib2vars.Grib2VarsTableLookup;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2Vcrd;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.comm.CommunicationException;
@ -97,6 +97,7 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
* 3/11/10 4758 bphillip Initial Creation
* 9/08/10 X. Guo Add new column
* 11/02/11 X. Guo Check octet size for isEnsmble()
* 3/2012 T. Lee Changed perturbation number to String
*
* </pre>
*
@ -113,7 +114,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
/** Set of Time range types for accumulations and averages */
private static final Set<Integer> AVG_ACCUM_LIST = new HashSet<Integer>();
private String traceId = "";
//private String traceId = "";
private NcgribDao dao;
private String fileName="";
@ -126,8 +127,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
private static final int[] fourtyTwo = new int[] { 1, 2, 1, 1, 2, 2, 3, 3,
4, 4, 5, 5 };
private static final int[] perturbation = new int[] { 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12 };
private static final String[] perturbation = new String[] { "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12" };
static {
AVG_ACCUM_LIST.add(3);
@ -262,8 +263,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
/*
* Decodes the parameter information from the record. An attempt is
* first made to map the gribimport gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
1 parameter to the equivalent grib 2
* first made to map the grib 1 parameter to the equivalent grib 2
* parameter. If this cannot be successfully executed, the grib 1
* parameter will be used from the parameter tables contained in the
* unidata decoder.
@ -329,7 +329,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
// rcg: added code to get perturbation
int pos41 = pdsVars.getOctet(41);
int pos42 = pdsVars.getOctet(42);
int pert = pdsVars.getID();
String pert = String.valueOf(pdsVars.getID());
for (int i = 0; i < perturbation.length; i++) {
if (pos41 == fourtyOne[i] && pos42 == fourtyTwo[i]) {
pert = perturbation[i];
@ -348,6 +348,11 @@ public class Ncgrib1Decoder extends AbstractDecoder {
createModelName(model);
// Get the level information
float glevel1 = (float) pdsVars.getLevelValue1();
float glevel2 = (float) pdsVars.getLevelValue2();
if ( vcrdid == 117 ) {
if ( glevel1 >= 32768 ) glevel1 = 32768 - glevel1;
}
float[] levelMetadata = this.convertGrib1LevelInfo(pdsVars
.getLevelType1(), (float) pdsVars
.getLevelValue1(), pdsVars
@ -356,6 +361,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
getLevelInfo(model, centerid, subcenterid, levelMetadata[0],
levelMetadata[1], levelMetadata[2], levelMetadata[3],
levelMetadata[4], levelMetadata[5]);
//int vcrd1 = (int)levelMetadata[0];
int vcrd2 = (int)levelMetadata[3];
// Construct the DataTime
GregorianCalendar refTime = new GregorianCalendar();
@ -478,42 +485,40 @@ public class Ncgrib1Decoder extends AbstractDecoder {
retVal.setCategory(category);
retVal.setParameterId(pid);
retVal.setProcessedDataType(pdsVars.getGenProcessId());
retVal.setDecodedLevel1( (float)model.getLevel().getLevelonevalue());
retVal.setDecodedLevel2((float)model.getLevel().getLeveltwovalue());
retVal.setDecodedLevel1((float)pdsVars.getLevelValue1());
retVal.setDecodedLevel2((float)pdsVars.getLevelValue2());
retVal.setVcrdId1(vcrdid);
retVal.setVcrdId2(vcrdid);
retVal.setGridVersion(1);
String vcord = "NONE";
String scale = "";
//TODO need to change this call to read the GRIB1 version of the vcrd table
// instead of the GRIB2 version...
Grib2Vcrd grib2Vcrd = Grib2VcrdTableLookup.getGrib2VcrdByGrib1VcrdId (vcrdid);
if ( grib2Vcrd != null ) {
vcord = grib2Vcrd.getGnam();
scale = grib2Vcrd.getScale();
Grib1Vcrd grib1Vcrd = Grib1VcrdTable.getGrib1VcrdById(vcrdid);
if ( grib1Vcrd != null ) {
vcord = grib1Vcrd.getGnam();
double scale = Double.parseDouble( grib1Vcrd.getScale() );
scale = Math.pow( 10., scale);
float dscale = (float)Math.pow ( 10, Double.parseDouble(scale));
float glevel1 = retVal.getDecodedLevel1();
if (glevel1 != 0 && dscale != 1 ) {
retVal.setGlevel1(Math.round(glevel1 * dscale));
if (glevel1 != 0 && scale != 1 ) {
retVal.setGlevel1((int)Math.round(glevel1 * scale));
}
else {
retVal.setGlevel1(Math.round(glevel1));
}
float glevel2 = retVal.getDecodedLevel2();
if ( glevel2 == -999999. ) {
if ( vcrd2 == 255 ) {
retVal.setGlevel2(-9999);
}
else {
if (glevel2 != 0 && dscale != 1 ) {
retVal.setGlevel2(Math.round(glevel2 * dscale));
if (glevel2 != 0 && scale != 1 ) {
retVal.setGlevel2((int)Math.round(glevel2 * scale));
}
else {
retVal.setGlevel2( Math.round(glevel2) );
}
}
}
else {
retVal.setGlevel1((int)model.getLevel().getLevelonevalue());
@ -907,8 +912,9 @@ public class Ncgrib1Decoder extends AbstractDecoder {
String gridid = model.getGridid();
int process = model.getGenprocess();
String template = model.getTemplate();
NcgridModel gridModel = NcgribModelLookup.getInstance().getModel(center,
subcenter, gridid, process);
subcenter, gridid, process, template, model);
String name = null;
if (gridModel == null) {
name = "UnknownModel:" + String.valueOf(center) + ":"
@ -1194,7 +1200,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
* The level two scale factor
* @param value2
* The level two value
* @throws GribException
* @throws GribException
*/
private void getLevelInfo(NcgribModel model, int centerID, int subcenterID,
float levelOneNumber, float scaleFactor1, float value1,
@ -1249,12 +1255,13 @@ public class Ncgrib1Decoder extends AbstractDecoder {
}
}
try {
Level level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
model.setLevel(level);
Level level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
model.setLevel(level);
} catch (CommunicationException e) {
throw new GribException("Error loading level.", e);
}
}
/**

View file

@ -21,13 +21,23 @@ package gov.noaa.nws.ncep.edex.plugin.ncgrib;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import ucar.grib.GribChecker;
import ucar.grib.grib1.Grib1Input;
import ucar.grib.grib1.Grib1Record;
import ucar.grib.grib2.Grib2Input;
import ucar.grib.grib2.Grib2Record;
import ucar.unidata.io.RandomAccessFile;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
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.edex.python.decoder.PythonDecoder;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
@ -43,6 +53,7 @@ import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp;
* ------------ ---------- ----------- --------------------------
* 3/12/10 4758 bphillip Initial creation
* 10/13/10 276 llin Modified for NC GRIB.
* 01/19/12 xguo Split large files
* </pre>
*
* @author njensen
@ -51,6 +62,12 @@ import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.TableTimeStamp;
public class NcgribDecoder {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(NcgribDecoder.class);
private static final long TEN_MEGABYTES = 10485760;
private static final long FIVE_MEGABYTES = 5242880;
public NcgribDecoder() {
}
@ -60,15 +77,81 @@ public class NcgribDecoder {
NcgribRecord[] records = null;
RandomAccessFile raf = null;
int edition = 0;
List<Long> recordLengths = new ArrayList<Long>();
try {
raf = new RandomAccessFile(file.getAbsolutePath(), "r");
if (raf == null){
throw new FileNotFoundException("Grib file does not exist ["+file.getAbsolutePath()+"]");
}
raf = new RandomAccessFile(file.getAbsolutePath(), "r");
raf.order(RandomAccessFile.BIG_ENDIAN);
edition = GribChecker.getEdition(raf);
} catch (IOException e) {
throw new GribException("Error checking ncgrib version", e);
// If the file is greater than ten megs, split it
if (file.length() > TEN_MEGABYTES) {
raf.seek(0);
if (edition == 1) {
Grib1Input g1i = new Grib1Input(raf);
g1i.scan(false, false);
List<Grib1Record> gribRecords = g1i.getRecords();
for (int i = 0; i < gribRecords.size(); i++) {
recordLengths.add(gribRecords.get(i).getIs()
.getGribLength());
}
} else if (edition == 2) {
Grib2Input g2i = new Grib2Input(raf);
try {
g2i.scan(false, false);
} catch (Exception e) {
throw new Exception(
"Error determining grib record count.", e);
}
List<Grib2Record> gribRecords = g2i.getRecords();
for (int i = 0; i < gribRecords.size(); i++) {
recordLengths.add(gribRecords.get(i).getIs()
.getGribLength());
}
}
if (recordLengths.size() > 1) {
raf.seek(0);
splitFile(file.getName(), raf, recordLengths);
try {
if (raf != null) {
raf.close();
}
} catch (IOException e) {
throw new GribException("", e);
}
return new NcgribRecord[] {};
}
}
if (edition == 1) {
records = new Ncgrib1Decoder().decode(file.getAbsolutePath());
} else if (edition == 2) {
//System.out.println("In decoder class edition 2, to update xml tables if necessary...");
TableTimeStamp.updateXmlTables();
PythonDecoder pythonDecoder = new PythonDecoder();
pythonDecoder.setPluginName("ncgrib");
pythonDecoder.setPluginFQN("gov.noaa.nws.ncep.edex.plugin.ncgrib");
pythonDecoder.setModuleName("NcgribDecoder");
pythonDecoder.setRecordClassname(NcgribRecord.class.toString());
pythonDecoder.setCache(true);
try {
PluginDataObject[] ncpdos = pythonDecoder.decode(file);
records = new NcgribRecord[ncpdos.length];
for (int i = 0; i < ncpdos.length; i++) {
records[i] = (NcgribRecord) ncpdos[i];
}
} catch (Exception e) {
throw new GribException("Error decoding ncgrib file!", e);
}
} else {
statusHandler.handle(Priority.ERROR,"Unknown ncgrib version detected [" + edition
+ "]");
}
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Failed to decode file: ["
+ file.getAbsolutePath() + "]", e);
records = new NcgribRecord[0];
} finally {
try {
if (raf != null) {
@ -78,33 +161,104 @@ public class NcgribDecoder {
throw new GribException("", e);
}
}
if (edition == 1) {
records = new Ncgrib1Decoder().decode(file.getAbsolutePath());
} else if (edition == 2) {
//System.out.println("In decoder class edition 2, to update xml tables if necessary...");
TableTimeStamp.updateXmlTables();
PythonDecoder pythonDecoder = new PythonDecoder();
pythonDecoder.setPluginName("ncgrib");
pythonDecoder.setPluginFQN("gov.noaa.nws.ncep.edex.plugin.ncgrib");
pythonDecoder.setModuleName("NcgribDecoder");
pythonDecoder.setRecordClassname(NcgribRecord.class.toString());
pythonDecoder.setCache(true);
try {
PluginDataObject[] ncpdos = pythonDecoder.decode(file);
records = new NcgribRecord[ncpdos.length];
for (int i = 0; i < ncpdos.length; i++) {
records[i] = (NcgribRecord) ncpdos[i];
}
} catch (Exception e) {
throw new GribException("Error decoding ncgrib file!", e);
}
} else {
throw new GribException("Unknown ncgrib version detected [" + edition
+ "]");
}
return records;
}
/**
* Splits a collective file into individual records.
*
* @param fileName
* The name of the file being split
* @param raf
* The Random Access File object
* @param sizes
* The sizes of the individual records inside the collection
* @throws IOException
*/
private void splitFile(String fileName, RandomAccessFile raf,
List<Long> sizes) throws IOException {
FileOutputStream out = null;
byte[] transfer = null;
long fileSize = 0,seekLoc;
int num = 0;
for (int i = 0; i < sizes.size(); i++) {
fileSize += sizes.get(i).longValue();
if ( (i < sizes.size() -1 ) &&
((fileSize + sizes.get(i+1).longValue())>FIVE_MEGABYTES)) {
num ++;
seekLoc = seekRecordStart(raf, raf.length());
if ( seekLoc < 0 ) return;
transfer = new byte[(int) fileSize];
raf.seek(seekLoc);
raf.read(transfer);
try {
out = new FileOutputStream(System.getProperty("edex.home")
+ "/data/sbn/ncgrib/" + fileName + "_" + num);
out.write(transfer);
out.close();
} finally {
if (out != null) {
out.close();
}
}
fileSize = 0;
}
}
if ( fileSize > 0 ) {
num ++;
seekLoc = seekRecordStart(raf, raf.length());
if ( seekLoc < 0 ) return;
transfer = new byte[(int) fileSize];
raf.seek(seekLoc);
raf.read(transfer);
try {
out = new FileOutputStream(System.getProperty("edex.home")
+ "/data/sbn/ncgrib/" + fileName + "_" + num);
out.write(transfer);
out.close();
} finally {
if (out != null) {
out.close();
}
}
}
}
/**
* Moves the filepointer on the random access file to the beginning of the
* next grib record in the file
*
* @param raf
* The random access file
* @param fileLength
* The total length of the file
* @return The index to the next grib record in the collection. -1 is
* returned if there are no more records in the file
* @throws IOException
*/
private long seekRecordStart(RandomAccessFile raf, long fileLength)
throws IOException {
int matches = 0;
while (raf.getFilePointer() < fileLength) {
char c = (char) raf.readByte();
if (c == 'G') {
matches = 1;
} else if ((c == 'R') && (matches == 1)) {
matches = 2;
} else if ((c == 'I') && (matches == 2)) {
matches = 3;
} else if ((c == 'B') && (matches == 3)) {
matches = 4;
// Subtract 4 because we want the absolute beginning of the grib
// file
return raf.getFilePointer() - 4;
} else {
matches = 0;
}
}
return -1;
}
}

View file

@ -112,70 +112,70 @@ public class NcgribDao extends NcepDefaultPluginDao {
this("ncgrib");
}
public void purgeExpiredData() {
QueryResult models = null;
try {
models = (QueryResult) executeNativeSql(MODEL_QUERY);
} catch (DataAccessLayerException e) {
logger.error("Error purging ncgrib data. Unable to get models", e);
}
String currentModel = null;
for (int i = 0; i < models.getResultCount(); i++) {
currentModel = (String) models.getRowColumnValue(i, 0);
QueryResult refTimes = null;
try {
refTimes = (QueryResult) executeNativeSql(REFTIME_QUERY
.replace("?", currentModel));
} catch (DataAccessLayerException e) {
logger
.error("Error purging ncgrib data. Unable to get reference times for model ["
+ currentModel + "]");
continue;
}
// FIXME: Add rules for purging here instead of just keeping 2
// runs
List<String> filesKept = new ArrayList<String>();
File modelDirectory = new File(PLUGIN_HDF5_DIR + File.separator
+ currentModel);
for (int j = 0; j < refTimes.getResultCount(); j++) {
Date time = (Date) refTimes.getRowColumnValue(j, 0);
File hdf5File = new File(modelDirectory.getAbsolutePath()
+ File.separator
+ ((NcgribPathProvider) pathProvider).formatTime(time)
+ ".h5");
if (j < MODELCOUNT) {
filesKept.add(hdf5File.getAbsolutePath());
continue;
}
try {
purgeDb(time, currentModel);
} catch (DataAccessLayerException e) {
logger.error("Error purging database for ncgrib model ["
+ currentModel + "]");
}
}
List<File> files = FileUtil.listFiles(modelDirectory, fileFilter,
false);
for (File file : files) {
if (!filesKept.contains(file.getAbsolutePath())) {
if (!file.delete()) {
logger
.error("Error purging HDF5 files for ncgrib model ["
+ currentModel + "]");
}
}
}
}
}
// public void purgeExpiredData() {
// QueryResult models = null;
// try {
// models = (QueryResult) executeNativeSql(MODEL_QUERY);
// } catch (DataAccessLayerException e) {
// logger.error("Error purging ncgrib data. Unable to get models", e);
// }
//
// String currentModel = null;
// for (int i = 0; i < models.getResultCount(); i++) {
// currentModel = (String) models.getRowColumnValue(i, 0);
// QueryResult refTimes = null;
// try {
// refTimes = (QueryResult) executeNativeSql(REFTIME_QUERY
// .replace("?", currentModel));
// } catch (DataAccessLayerException e) {
// logger
// .error("Error purging ncgrib data. Unable to get reference times for model ["
// + currentModel + "]");
// continue;
// }
//
// // FIXME: Add rules for purging here instead of just keeping 2
// // runs
// List<String> filesKept = new ArrayList<String>();
// File modelDirectory = new File(PLUGIN_HDF5_DIR + File.separator
// + currentModel);
//
// for (int j = 0; j < refTimes.getResultCount(); j++) {
// Date time = (Date) refTimes.getRowColumnValue(j, 0);
// File hdf5File = new File(modelDirectory.getAbsolutePath()
// + File.separator
// + ((NcgribPathProvider) pathProvider).formatTime(time)
// + ".h5");
//
// if (j < MODELCOUNT) {
// filesKept.add(hdf5File.getAbsolutePath());
// continue;
// }
//
// try {
// purgeDb(time, currentModel);
// } catch (DataAccessLayerException e) {
// logger.error("Error purging database for ncgrib model ["
// + currentModel + "]");
// }
// }
//
// List<File> files = FileUtil.listFiles(modelDirectory, fileFilter,
// false);
//
// for (File file : files) {
// if (!filesKept.contains(file.getAbsolutePath())) {
// if (!file.delete()) {
// logger
// .error("Error purging HDF5 files for ncgrib model ["
// + currentModel + "]");
// }
// }
// }
//
// }
//
// }
private int purgeDb(final Date date, String modelName)
throws DataAccessLayerException {

View file

@ -0,0 +1,191 @@
/**
* This file was generated by the JavaTM Architecture for XML Binding(JAXB)
* Reference Implementation, vJAXB 2.1.10 in JDK 6
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
* any modifications to this file will be lost upon recompilation of the source schema
* Generated on: 2010.09.10 at 11:48:39 AM EDT
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 10/2010 276 L. Lin Initial creation
*
* </pre>
*
* This code has been developed by the SIB for use in the AWIPS2 system.
* @author L. Lin
* @version 1.0
*/
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element ref="{}vcrdid1" minOccurs="0"/>
* &lt;element ref="{}name" minOccurs="0"/>
* &lt;element ref="{}units" minOccurs="0"/>
* &lt;element ref="{}gnam" minOccurs="0"/>
* &lt;element ref="{}scale" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"vcrdid",
"name",
"units",
"gnam",
"scale"
})
@XmlRootElement(name = "grib1vcrd")
public class Grib1Vcrd implements ISerializableObject {
protected Integer vcrdid;
protected String name;
protected String units;
protected String gnam;
protected String scale;
/**
* Gets the value of the vcrdid property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getVcrdid() {
return vcrdid;
}
/**
* Sets the value of the vcrdid property.
*
* @param value
* allowed object is
* {@link Integer }
*
public void setVcrdid(Integer value) {
this.vcrdid = value;
}
*/
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
public void setName(String value) {
this.name = value;
}
*/
/**
* Gets the value of the units property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getUnits() {
return units;
}
/**
* Sets the value of the units property.
*
* @param value
* allowed object is
* {@link String }
*
public void setUnits(String value) {
this.units = value;
}
*/
/**
* Gets the value of the gnam property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getGnam() {
return gnam;
}
/**
* Sets the value of the gnam property.
*
* @param value
* allowed object is
* {@link String }
*
public void setGnam(String value) {
this.gnam = value;
}
*/
/**
* Gets the value of the scale property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getScale() {
return scale;
}
/**
* Sets the value of the scale property.
*
* @param value
* allowed object is
* {@link String }
*
public void setScale(String value) {
this.scale = value;
}
*/
}

View file

@ -0,0 +1,76 @@
/**
* This file was generated by the JavaTM Architecture for XML Binding(JAXB)
* Reference Implementation, vJAXB 2.1.10 in JDK 6
* See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
* any modifications to this file will be lost upon recompilation of the source schema
* Generated on: 2010.09.10 at 11:48:39 AM EDT
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 10/2010 276 L. Lin Initial creation
*
* </pre>
*
* This code has been developed by the SIB for use in the AWIPS2 system.
* @author L. Lin
* @version 1.0
*/
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"grib1Vcrd"
})
@XmlRootElement(name = "grib1vcrdList")
public class Grib1VcrdList implements ISerializableObject {
@XmlElement(name = "grib1vcrd")
protected List<Grib1Vcrd> grib1Vcrd;
/**
* Gets the value of the grib1Vcrd property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the grib1Vcrd property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getGrib1Vcrd().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Grib1Vcrd }
*
*
*/
public List<Grib1Vcrd> getGrib1Vcrd() {
if (grib1Vcrd == null) {
grib1Vcrd = new ArrayList<Grib1Vcrd>();
}
return this.grib1Vcrd;
}
}

View file

@ -0,0 +1,85 @@
package gov.noaa.nws.ncep.edex.util.grib1vcrd;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
/**
*/
public class Grib1VcrdTable {
private static final String file = "ncgrid" + File.separator + "grib1vcrd.xml";
private static Grib1VcrdList g1VcrdList;
private static Map<Integer, Grib1Vcrd> vcordMap = null;
private static void readGrib1VcrdTable( String xmlFilename ) throws SerializationException{
g1VcrdList = (Grib1VcrdList)SerializationUtil.jaxbUnmarshalFromXmlFile(xmlFilename);
}
/**
* Search a g2Vcrd given a field, and search key value.
*
* @param sf
* @param key
* @return Grib2Vcrd
*/
public static Grib1Vcrd getGrib1VcrdById (int vcrdid ) {
synchronized (Grib1VcrdTable.class) {
if (g1VcrdList == null) {
System.out.println("INITIALIZINGVCRD!!!!!!");
try {
String filename = findVcrdTable();
readGrib1VcrdTable(filename);
createMapOfTable();
} catch (Exception e) {
e.printStackTrace();
g1VcrdList = null;
return null;
}
}
}
if ( vcordMap.containsKey(vcrdid) )
return vcordMap.get(vcrdid);
else
return null;
}
private static void createMapOfTable() {
vcordMap = new HashMap<Integer, Grib1Vcrd>();
for ( Grib1Vcrd vcord : g1VcrdList.getGrib1Vcrd() ) {
vcordMap.put(vcord.getVcrdid(), vcord);
}
}
private static String findVcrdTable() throws IOException{
String filename = null;
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticBase = pathMgr.getContext(
LocalizationContext.LocalizationType.COMMON_STATIC,
LocalizationContext.LocalizationLevel.BASE);
filename = pathMgr.getFile( commonStaticBase, Grib1VcrdTable.file).getCanonicalPath();
return filename;
}
}

View file

@ -19,6 +19,7 @@
**/
package gov.noaa.nws.ncep.edex.util.ncgrib;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModelSet;
@ -29,6 +30,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -43,11 +45,12 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 3/12/10 4758 bphillip Initial creation
* 10/13/10 276 llin Modified for NC GRIB.
* 11/02/11 xguo Updated gridid
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 3/12/10 4758 bphillip Initial creation
* 10/13/10 276 llin Modified for NC GRIB.
* 11/02/11 xguo Updated gridid
* 3/2012 T. Lee Get ensemble modelName via template
* </pre>
*
* @author njensen
@ -99,8 +102,85 @@ public class NcgribModelLookup {
}
public NcgridModel getModel(int center, int subcenter, String grid,
int process) {
return models.get(toHash(center, subcenter, grid, process));
int process, String filename, NcgribModel nbm) {
NcgridModel model = new NcgridModel ();
model = models.get(toHash(center, subcenter, grid, process));
if ( model == null ) {
return model;
}
String template = model.getTemplate();
//System.out.println ( " Center: "+ center + " subCenter: "+ subcenter + " gridID: " + grid
// + " modelID: "+ process + " modelName: " + model.getName() );
if ( !template.equals("NONE")) {
/*
* Using Template to get ModelName
*/
String[] tokens = template.replaceAll("\\s","").split(";");
// CMC ensemble
if ( Pattern.matches("cmc.*", filename)){
//System.out.println ( " CMC ensemble " + "!!!\n");
for ( String token : tokens ) {
String[] alias = token.split("\\|");
if ( Pattern.matches(alias[0], filename) ) {
model.setName(alias[1]);
break;
}
}
// SREF ensemble
} else if ( Pattern.matches("sref.*", filename)) {
for ( String token : tokens ) {
String[] alias = token.split("\\|");
if ( Pattern.matches(alias[0], filename)) {
model.setName(alias[1]);
// perturbation number
String[] pert = filename.split("\\.");
if ( pert[3].startsWith("p") || pert[3].startsWith("n")) {
nbm.setPerturbationNumber(pert[3]);
}
break;
}
}
// NAEFS ensemble
} else if ( Pattern.matches("naefs.*", filename)) {
for ( String token : tokens ) {
String[] alias = token.split("\\|");
if ( Pattern.matches(alias[0], filename)) {
model.setName(alias[1]);
break;
}
}
// GEFS ensemble
} else if ( Pattern.matches("ge.*", filename)) {
for ( String token : tokens ) {
String[] alias = token.split("\\|");
if ( Pattern.matches(alias[0], filename)) {
model.setName(alias[1]);
break;
}
}
// GWW derived data
} else if ( Pattern.matches("mean.*", filename) ||
Pattern.matches("probab.*", filename) ||
Pattern.matches("spread.*", filename)) {
for ( String token : tokens ) {
String[] alias = token.split("\\|");
if ( Pattern.matches(alias[0], filename)) {
model.setName(alias[1]);
break;
}
}
}
}
return model;
}
public synchronized void setModel(int center, int subcenter, String grid,
@ -120,8 +200,8 @@ public class NcgribModelLookup {
}
public NcgridModel getModel(int center, int subcenter, int gridid,
int process) {
return getModel(center, subcenter, String.valueOf(gridid), process);
int process, String filename, NcgribModel model) {
return getModel(center, subcenter, String.valueOf(gridid), process, filename, model);
}
public NcgridModel getModelByName(String name) {

View file

@ -105,7 +105,7 @@
<name>Layer between two spec alts (msl)</name>
<units>hm</units>
<gnam>HGHT</gnam>
<scale>2</scale>
<scale>0</scale>
</grib1vcrd>
<grib1vcrd>
<vcrdid>105</vcrdid>
@ -119,21 +119,21 @@
<name>Layer between two height levels (gnd)</name>
<units>hm</units>
<gnam>HGHT</gnam>
<scale>2</scale>
<scale>0</scale>
</grib1vcrd>
<grib1vcrd>
<vcrdid>107</vcrdid>
<name>Sigma level</name>
<units>1/10000 sigma value</units>
<gnam>SGMA</gnam>
<scale>0</scale>
<scale>4</scale>
</grib1vcrd>
<grib1vcrd>
<vcrdid>108</vcrdid>
<name>Layer between two sigma levels</name>
<units>1/100 sigma values</units>
<gnam>SGMA</gnam>
<scale>2</scale>
<scale>4</scale>
</grib1vcrd>
<grib1vcrd>
<vcrdid>109</vcrdid>
@ -203,7 +203,7 @@
<name>ETA level</name>
<units>1/10000</units>
<gnam>ELVL</gnam>
<scale>0</scale>
<scale>4</scale>
</grib1vcrd>
<grib1vcrd>
<vcrdid>120</vcrdid>

View file

@ -4191,6 +4191,18 @@
<scale>0</scale>
<missing>-9999.00</missing>
</grib2vars>
<grib2vars>
<g2varsid>888</g2varsid>
<discipline>0</discipline>
<category>19</category>
<pid>232</pid>
<pdt>0</pdt>
<name>Volcanic Ash Forecast Transport and Dispersion</name>
<units>log10(kg m**-3)</units>
<gnam>VAFTAD</gnam>
<scale>0</scale>
<missing>-9999.00</missing>
</grib2vars>
<grib2vars>
<g2varsid>888</g2varsid>
<discipline>0</discipline>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<latLonNcgridCoverage>
<name>372</name>
<description>Global ECMWF 361X181 Latitude/Longitude 1 deg Resolution</description>
<nx>361</nx>
<ny>181</ny>
<la1>90</la1>
<lo1>0</lo1>
<la2>-90</la2>
<lo2>360</lo2>
<dx>1</dx>
<dy>1</dy>
<spacingUnit>degree</spacingUnit>
</latLonNcgridCoverage>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<latLonNcgridCoverage>
<name>36928220</name>
<description>HYSPLIT</description>
<nx>314</nx>
<ny>83</ny>
<la1>36.9</la1>
<lo1>-77.1</lo1>
<la2>45.1</la2>
<lo2>-45.8</lo2>
<dx>0.1</dx>
<dy>0.1</dy>
<spacingUnit>degree</spacingUnit>
</latLonNcgridCoverage>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<latLonNcgridCoverage>
<name>401</name>
<description>Global 360X181 Latitude/Longitude 1 deg Resolution</description>
<nx>360</nx>
<ny>181</ny>
<la1>-90</la1>
<lo1>0</lo1>
<la2>90</la2>
<lo2>359</lo2>
<dx>1</dx>
<dy>1</dy>
<spacingUnit>degree</spacingUnit>
</latLonNcgridCoverage>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<polarStereoNcgridCoverage>
<name>172</name>
<description>Southern Hemisphere High Resolution Sea Ice Grid
(polar stereographic)</description>
<minorAxis>6371229.0</minorAxis>
<majorAxis>6371229.0</majorAxis>
<nx>690</nx>
<ny>710</ny>
<la1>-36.899599</la1>
<lo1>139.805573</lo1>
<lov>100</lov>
<dx>12.7</dx>
<dy>12.7</dy>
<spacingUnit>km</spacingUnit>
</polarStereoNcgridCoverage>

View file

@ -22,7 +22,7 @@
<name>228</name>
<description> Global (longitude/latitude grid)</description>
<nx>144</nx>
<ny>83</ny>
<ny>73</ny>
<la1>90</la1>
<lo1>0</lo1>
<la2>-90</la2>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<latLonNcgridCoverage>
<name>72051</name>
<description>0.167 degree Latitude/Longitude for the US East Coast grid</description>
<nx>720</nx>
<ny>51</ny>
<la1>90</la1>
<lo1>65</lo1>
<la2>0</la2>
<lo2>359.5</lo2>
<dx>0.5</dx>
<dy>0.5</dy>
<spacingUnit>degree</spacingUnit>
</latLonNcgridCoverage>

View file

@ -1,4 +1,28 @@
# Product Discipline 0: Meteorological products, Parameter Category 19: Physical atmospheric properties
0:0:Visibility:m:VIS
1:1:Albedo:%:ALBDO
2:2:Thunderstorm Probability:%:TSTM
3:3:Mixed Layer Depth:m:MIXHT
4:4:Volcanic Ash:See Table 4.206:VOLASH
5:5:Icing Top:m:ICIT
6:6:Icing Base:m:ICIB
7:7:Icing:See Table 4.207:ICI
8:8:Turbulence Top:m:TURBT
9:9:Turbulence Base:m:TURBB
10:10:Turbulence:See Table 4.208:TURB
11:11:Turbulent Kinetic Energy:J kg-1:TKE
12:12:Planetary Boundary Layer Regime:See Table 4.209:PBLREG
13:13:Contrail Intensity:See Table 4.210:CONTI
14:14:Contrail Engine Type:See Table 4.211:CONTET
15:15:Contrail Top:m:CONTT
16:16:Contrail Base:m:CONTB
17:17:Maximum Snow Albedo*:%:MXSALB
18:18:Snow-Free Albedo:%:SNFALB
19:19:Snow Albedo:%:SALBD
20:20:Icing:%:ICIP
21:21:In-Cloud Turbulence:%:CTP
22:22:Clear Air Turbulence (CAT):%:CAT
23:23:Supercooled Large Droplet (SLD) Probabilitysee note 1:%:SLDP
#192-254 Reserved for local use
192:192:Maximum Snow Albedo:%:MXSALB
193:193:Snow-Free Albedo:%:SNFALB

View file

@ -1573,13 +1573,14 @@ public class NcPirepParser {
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
matcher = pattern.matcher(str); //need to re-match
matcher = pattern.matcher(str); //need to re-match. LGT RIME 014-083
while (matcher.find()) {
addFlightCondition(matcher, theIcingLayers);
//System.out.println("***str "+str);
addFlightCondition(matcher, theIcingLayers);
}
}
else {
Pattern pattern2 = Pattern.compile("([A-Z]{3,5})"); //only intensity
Pattern pattern2 = Pattern.compile("([A-Z]{3,5})"); //only intensity. LGT
Matcher matcher2 = pattern2.matcher(str);
while (matcher2.find()) {
@ -1690,7 +1691,7 @@ public class NcPirepParser {
if(matcher.groupCount() >= 13) {
String s1 = matcher.group(1);
String s2 = matcher.group(3);
//System.out.println("***matcher "+matcher.group(0)); //MOD null null RIME RIME null null null
// Some words that may show up in group 1 or 3 that need to be
// thrown away!
s1 = WX_COND_WORDS.get(s1);

View file

@ -21,7 +21,7 @@ import com.raytheon.uf.edex.decodertools.aircraft.WordTranslator;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 10, 2011 jkorman Initial creation
*
* 2012/02/15 #680 Q.Zhou Changed CAT and CHOP typo
* </pre>
*
* @author jkorman
@ -129,8 +129,8 @@ public class PirepTools {
TURBC_WORDS.enter("EXTRE", "EXTRM", false, TURBC_INT_EXTRM, INT_ID);
TURBC_WORDS.enter("XTRM", "EXTRM", false, TURBC_INT_EXTRM, INT_ID);
TURBC_WORDS.enter("CHOP", "CHOP", false, TURBC_TYP_CAT, TYP_ID);
TURBC_WORDS.enter("CAT", "CAT", false, TURBC_TYP_CHOP, TYP_ID);
TURBC_WORDS.enter("CAT", "CAT", false, TURBC_TYP_CAT, TYP_ID);
TURBC_WORDS.enter("CHOP", "CHOP", false, TURBC_TYP_CHOP, TYP_ID);
TURBC_WORDS.enter("LLWS", "LLWS", false, TURBC_TYP_LLWS, TYP_ID);
TURBC_WORDS.enter("ABV", "ABV", false, MOD_ID_ABV, MOD_ID);

View file

@ -84,7 +84,7 @@ public class NctextFileNameGenerator {
*/
public synchronized PluginDataObject[] renameAndDecodeFile(File fileToRename) throws IOException{
//logger.debug("renameAndDecodeFile() called...");
System.out.println("renameAndDecodeFile() invoked");
//System.out.println("renameAndDecodeFile() invoked");
PluginDataObject[] srcArray = new PluginDataObject[0];
List<PluginDataObject> dynamicDestArray = new ArrayList<PluginDataObject>(0);
this.formattedFileNameList = new ArrayList<String>(0);
@ -94,9 +94,9 @@ public class NctextFileNameGenerator {
String[] linesOfFileHeader = fileHeader.split(System.getProperty("line.separator"));
if(linesOfFileHeader != null && linesOfFileHeader.length > 1){
// System.out.println("Date of file creation: "+ this.fileCreatedCalendar.getTime().toString());
for(int k =0; k < linesOfFileHeader.length; k++){
System.out.println("Line "+ k + " ="+ linesOfFileHeader[k]);
}
//for(int k =0; k < linesOfFileHeader.length; k++){
// System.out.println("Line "+ k + " ="+ linesOfFileHeader[k]);
//}
int i=0;
while( i < linesOfFileHeader.length - 1){
@ -121,9 +121,9 @@ public class NctextFileNameGenerator {
if (this.formattedFileNameList.size() > 0) {
// System.out.println("The final list of formatted file names: "+ this.formattedFileNameList);
boolean isFileRenamedInPostProcess = false;
for(int p =0; p < formattedFileNameList.size(); p++){
System.out.println("File name "+p+ " ="+formattedFileNameList.get(p));
}
//for(int p =0; p < formattedFileNameList.size(); p++){
// System.out.println("File name "+p+ " ="+formattedFileNameList.get(p));
//}
int index = 0;
int listSize = this.formattedFileNameList.size();
while(index < listSize && !isFileRenamedInPostProcess){
@ -143,21 +143,21 @@ public class NctextFileNameGenerator {
isFileRenamedInPostProcess = true;
}
System.out.println("New name for file: "+ outFilePath);
//System.out.println("New name for file: "+ outFilePath);
srcArray = decodeFile(fileToRename, outFilePath);
pdoList = new ArrayList<PluginDataObject>(Arrays.asList(srcArray));
dynamicDestArray.addAll(pdoList);
index++;
}
}else{
System.out.println("No match found with any regular expression- file= "+ fileToRename.getName());
//Chin:TESTING
//srcArray = decodeFile(fileToRename, fileToRename.getName());
//System.out.println("No match found with any regular expression- file= "+ fileToRename.getName());
//Chin:TESTING
//srcArray = decodeFile(fileToRename, fileToRename.getName());
// pdoList = new ArrayList<PluginDataObject>(Arrays.asList(srcArray));
//dynamicDestArray.addAll(pdoList);
//dynamicDestArray.addAll(pdoList);
}
System.out.println("The final array length : " + dynamicDestArray.size());
//System.out.println("The final array length : " + dynamicDestArray.size());
PluginDataObject[] returnArray = new PluginDataObject[0];
return dynamicDestArray.toArray(returnArray);
@ -282,6 +282,8 @@ public class NctextFileNameGenerator {
this.formattedFileNameList.add( DATE_WITH_HOUR.format(tempCal.getTime()) + "." + fileExtension);
}
}
//else
// System.out.println("product size =0");
}
return (this.formattedFileNameList.size() > 0 ? true: false );

View file

@ -85,27 +85,37 @@ public final class NctextRegexMatcher {
// System.out.println("Current line in file is: " + fileContent);
//retrieve the matching product type for the regular expression
String prodType = new String(NCTEXT_PRODUCT_REGEX_MAP.get(thisPattern));
//System.out.println("Product type is " + prodType);
//System.out.println("Matching pattern is: " + thisPattern.pattern());
//If the product type is not already in the list...
if(!isNctextProductAlreadyInList(prodType)){
//add it to the list
strNctextProductType.add(prodType);
System.out.println("Product type is " + prodType);
System.out.println("Matching pattern is: " + thisPattern.pattern());
}
//System.out.println("matchFileRegex group count =" + thisMatcher.groupCount() );
//for(int i=0; i< thisMatcher.groupCount();i++){
// System.out.println("matchFileRegex group " + i+ "= "+thisMatcher.group(i));
//}
if(thisMatcher.groupCount() > 1){
//get the data captured from the groups of the matcher
String dateFromMatchedPattern = new String(thisMatcher.group(1));
String hourFromMatchedPattern = new String(thisMatcher.group(2));
String minuteFromMatchedPattern = new String(thisMatcher.group(3));
parsedDate = new Integer(Integer.parseInt(dateFromMatchedPattern));
parsedHour = new Integer(Integer.parseInt(hourFromMatchedPattern));
parsedMinute = new Integer(Integer.parseInt(minuteFromMatchedPattern));
try{
parsedDate = new Integer(Integer.parseInt(dateFromMatchedPattern));
parsedHour = new Integer(Integer.parseInt(hourFromMatchedPattern));
parsedMinute = new Integer(Integer.parseInt(minuteFromMatchedPattern));
} catch (NumberFormatException e){
System.out.println("matchFileRegex(): NumberFormatException event: for product type "+prodType);
continue;
}
}
isMatchFound = true;
}
thisMatcher.reset();
}
//System.out.println("matchFileRegex returning "+ isMatchFound);
return isMatchFound;
}
/***
@ -149,7 +159,12 @@ public final class NctextRegexMatcher {
thisMap.put(Pattern.compile("^FXUS[67][1-6] .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
thisMap.put(Pattern.compile("^FPAK20 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");//no data to test
thisMap.put(Pattern.compile("^FPHW03 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");//no data to test
thisMap.put(Pattern.compile("^FX(HW|PN|PS)60 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
//thisMap.put(Pattern.compile("^FX(HW|PN|PS)60 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
//split above pattern to the following 3 patterns so matchFileRegex() can be coded in a generic way.
thisMap.put(Pattern.compile("^FXHW60 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
thisMap.put(Pattern.compile("^FXPN60 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
thisMap.put(Pattern.compile("^FXPS60 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "area");
thisMap.put(Pattern.compile("^...... .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).*(\n|\r)FA[0-9].*"), "area"); //aviation forecasts
thisMap.put(Pattern.compile("^WWUS30 KWNS (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"),"wtch2");
thisMap.put(Pattern.compile("^FNUS21 KWNS (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"),"fwddy1");
@ -190,7 +205,7 @@ public final class NctextRegexMatcher {
thisMap.put(Pattern.compile("^FAAK2[1-6] KZAN (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "cwa");
thisMap.put(Pattern.compile("^FAUS2[1-6] KZ.. (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "cwa");
thisMap.put(Pattern.compile("^WCUS2[1-6] KZ.. (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "cwa");
thisMap.put(Pattern.compile("^FAUS20 (KZ..|PANC) (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "mis");
thisMap.put(Pattern.compile("^FAUS20 PANC (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "mis");
thisMap.put(Pattern.compile("^FOUS14 KWNO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "ngmmos");
thisMap.put(Pattern.compile("^FOAK2[5-9] KWNO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "ngmmos");
thisMap.put(Pattern.compile("^FOPA20 KWNO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "gfsmos");
@ -310,7 +325,23 @@ public final class NctextRegexMatcher {
thisMap.put(Pattern.compile("^SXUS86 .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "cgr");//regexes clash for cgr and OMR
thisMap.put(Pattern.compile("^WV.... .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "vlcw"); //might clash with regex for inl and sgmt
thisMap.put(Pattern.compile("^W[CSV].... [^KP]... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV](NT|PN|PA|AK)[01][0-9] (KKCI|PHFO|PAWU) (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
//thisMap.put(Pattern.compile("^W[CSV](NT|PN|PA|AK)[01][0-9] (KKCI|PHFO|PAWU) (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
//split above pattern to the following 12 patterns so matchFileRegex() can be coded in a generic way.
thisMap.put(Pattern.compile("^W[CSV](NT|PN|PA|AK)[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]NT[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]NT[01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]NT[01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PN[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PN[01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PN[01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PA[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PA[01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]PA[01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]AK[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]AK[01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^W[CSV]AK[01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "intl"); //regexes clash for intl and sgmt
thisMap.put(Pattern.compile("^WSUS4[012] .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "conv");
thisMap.put(Pattern.compile("^W[CSV]US0[1-6] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "sgmt");
thisMap.put(Pattern.compile("^WSUK.. .... (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9])(.|\r|\n)+"), "sgmt");

View file

@ -40,9 +40,9 @@
<regex>^WWJP25 RJTD (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^WCPA3[1-5] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^WSUS3[1-3] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV][NT|PN|PA|AK][01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV][NT|PN|PA|AK][01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV][NT|PN|PA|AK][01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV](NT|PN|PA|AK)[01][0-9] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV](NT|PN|PA|AK)[01][0-9] PHFO (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV](NT|PN|PA|AK)[01][0-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^W[CSV]US0[1-6] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).*</regex>
<regex>^WAUS4[1-6] KKCI (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>
<regex>^WAAK4[7-9] PAWU (0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]).+</regex>

View file

@ -0,0 +1 @@
gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairRecord

View file

@ -31,14 +31,15 @@ Export-Package: gov.noaa.nws.ncep.edex.uengine.output,
gov.noaa.nws.ncep.edex.uengine.utility
Import-Package: com.raytheon.edex.plugin.modelsounding.common,
com.raytheon.uf.common.dataplugin.bufrua,
com.raytheon.uf.common.dataplugin.bufrua.dao,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.edex.pointdata,
gov.noaa.nws.ncep.common.tools,
gov.noaa.nws.ncep.edex.common.metparameters,
gov.noaa.nws.ncep.edex.common.metparameters.parameterconversion,
gov.noaa.nws.ncep.edex.plugin.ncgrib.dao,
gov.noaa.nws.ncep.edex.common.metparameters,
javax.measure.converter,
javax.measure.unit,
org.apache.commons.logging,

View file

@ -13,6 +13,9 @@ package gov.noaa.nws.ncep.edex.uengine.tasks.profile;
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 04/04/2011 301 Chin Chen Initial coding
* 02/28/2012 Chin Chen modify several sounding query algorithms for better performance
* 03/28/2012 Chin Chen Add new API to support query multiple Points at one shoot and using
* dataStore.retrieveGroups()
*
* </pre>
*
@ -24,11 +27,13 @@ import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingModel;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
import java.util.ArrayList;
import java.util.List;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import com.raytheon.edex.plugin.modelsounding.common.SoundingSite;
import com.raytheon.uf.edex.database.DataAccessLayerException;
@ -67,7 +72,8 @@ public class MdlSoundingQuery {
private static final String NCGRIB_TBL_NAME = "ncgrib";
private static final String D2DGRIB_TBL_NAME = "grib";
private static String NC_PARMS = "HGHT, UREL, VREL, TMPK, DWPK, SPFH, OMEG, RELH";
private static String NC_PARMS = "HGHT, UREL, VREL, TMPK, OMEG, RELH";
//private static String NC_PARMS = "HGHT, UREL, VREL, TMPK, DWPK, SPFH, OMEG, RELH";
private static String D2D_PARMS = "GH, uW, vW,T, DWPK, SPFH,OMEG, RH";
private enum NcParmNames {
HGHT, UREL, VREL, TMPK, DWPK, SPFH, OMEG, RELH
@ -80,6 +86,7 @@ public class MdlSoundingQuery {
public static UnitConverter kelvinToCelsius = SI.KELVIN
.getConverterTo(SI.CELSIUS);
private static final UnitConverter metersPerSecondToKnots = SI.METERS_PER_SECOND.getConverterTo(NonSI.KNOT);
public static NcSoundingTimeLines getMdlSndTimeLine(String mdlType,
String currentDBTblName) {
@ -127,7 +134,7 @@ public class MdlSoundingQuery {
String queryStr = new String("Select Distinct rangestart FROM "
+ currentDBTblName + " where modelname='" + mdlType + "' AND "
+ "reftime='" + refTimeStr + ":00:00'"
+ " ORDER BY rangestart DESC");
+ " ORDER BY rangestart");
System.out.println("queryStr " + queryStr);
CoreDao dao = new CoreDao(DaoConfig.forClass(SoundingSite.class));
@ -141,7 +148,7 @@ public class MdlSoundingQuery {
query.setDistinctField("dataTime.validPeriod.start");
query.addParameter("modelInfo.modelName", mdlType);
query.addParameter("dataTime.refTime", refTimeStr + ":00:00");
query.setSortBy("dataTime.validPeriod.start", false);
query.setSortBy("dataTime.validPeriod.start", true);
@SuppressWarnings("unchecked")
List<GribRecord> recList = (List<GribRecord>) query.execute();
tl.setTimeLines(recList.toArray());
@ -169,6 +176,96 @@ public class MdlSoundingQuery {
// mdlName);
// }
/**
* Returns a list of profile for location (lat,lon) array, time, and model for
* grib or ncgrib data.
*
* @param double[][] latLonArray, e.g. at nth element, lat=[n][0], lon=[n][1]
* @param refTimeCal
* data record reference time
* @param validTimeCal
* data record valid time
* @param pluginName
* the name of the data table ('grib' or 'ncgrib')
* @param mdlName
* the name of the model
* @return the profile
* created @ 3/28/2012
*/
public static List<NcSoundingProfile> getMdlSndDataProfileList(double[][] latLonArray,
String refTime, String validTime, String pluginName, String mdlName) {
double lat, lon;
//System.out.println("getMdlSndData lat=" + lat + " lon="+lon);
long t01 = System.currentTimeMillis();
NcSoundingProfile pf = new NcSoundingProfile();
//NcSoundingCube cube = new NcSoundingCube();
List<NcSoundingProfile> soundingProfileList = new ArrayList<NcSoundingProfile>();
List<?> levels = getModelLevels(refTime, validTime, pluginName, mdlName);
if (levels.size() == 0) {
System.out.println("getModelLevels return 0; file=" + refTime+ " stime="+validTime + " gribtype="+ pluginName + " modeltype="+mdlName);
return soundingProfileList;
}
//System.out.println("getModelLevels = "+ levels.size()+" levels, took "+ (System.currentTimeMillis()-t01) + " ms");
List<Point> points = new ArrayList<Point>();
for(int k =0; k< latLonArray.length; k++){
lat=latLonArray[k][0];
lon=latLonArray[k][1] ;
Point pnt = getLatLonIndices(lat, lon, refTime, validTime, levels.get(0).toString(),
pluginName, mdlName);
if (pnt == null) {
System.out.println("getLatLonIndices return 0; lat=" + lat + " lon="+lon+" stime="+validTime + " gribtype="+ pluginName + " modeltype="+mdlName);
}
else{
points.add(pnt);
}
}
if(points.size()==0){
return soundingProfileList;
}
long t011 = System.currentTimeMillis();
soundingProfileList = queryProfileListByPointGroup(points,
refTime, validTime, pluginName, mdlName, levels);
System.out.println("queryProfileListByPointGroup took "+ (System.currentTimeMillis()-t011) + " ms");
return soundingProfileList;
/* The floowing should be done in queryProfileListByPointGroup()
//System.out.println("getModelSoundingLayerList= "+ layerList.size()+ " layers, took "+ (System.currentTimeMillis()-t012) + " ms");
//pf.setStationLatitude( lat);
//pf.setStationLongitude( lon);
//Float sfcPressure = getModelSfcPressure(pnt, refTime, validTime,
// pluginName, mdlName);
//System.out.println("getModelSfcPressure took "+ (System.currentTimeMillis()-t013) + " ms");
//if (sfcPressure == null) {
// pf.setSfcPress(-9999.f);
//}
//else {
// if (pluginName.equalsIgnoreCase(D2DGRIB_TBL_NAME))
// pf.setSfcPress(sfcPressure/100F);
// else
// pf.setSfcPress(sfcPressure);
//}
//System.out.println("surface pressure ="+pf.getSfcPress()+ " lat= "+lat+ " lon="+lon);
//calculate dew point if necessary
long t014 = System.currentTimeMillis();
MergeSounding ms = new MergeSounding();
//ms.spfhToDewpoint(layerList);
ms.rhToDewpoint(layerList);
System.out.println("MergeSounding took "+ (System.currentTimeMillis()-t014) + " ms");
pf.setSoundingLyLst(layerList);
soundingProfileList.add(pf);
//cube.setSoundingProfileList(soundingProfileList);
//cube.setRtnStatus(NcSoundingCube.QueryStatus.OK);
long t02 = System.currentTimeMillis();
System.out.println("MDL cube retreival took " + (t02 - t01));
return pf;
*/
}
/**
* Returns a profile for a specified location (lat,lon), time, and model for
* grib or ncgrib data.
@ -186,20 +283,20 @@ public class MdlSoundingQuery {
* @param mdlName
* the name of the model
* @return the profile
*/
*
public static NcSoundingProfile getMdlSndData(double lat, double lon,
String refTime, String validTime, String pluginName, String mdlName) {
System.out.println("getMdlSndData lat=" + lat + " lon="+lon);
long t01 = System.currentTimeMillis();
NcSoundingProfile pf = new NcSoundingProfile();
//NcSoundingCube cube = new NcSoundingCube();
List<NcSoundingProfile> soundingProfileList = new ArrayList<NcSoundingProfile>();
List<?> levels = getModelLevels(refTime, validTime, pluginName, mdlName);
if (levels.size() == 0) {
System.out.println("getModelLevels return 0; file=" + refTime+ " stime="+validTime + " gribtype="+ pluginName + " modeltype="+mdlName);
pf.setRtnStatus(NcSoundingCube.QueryStatus.FAILED);
return pf;
}
System.out.println("getModelLevels = "+ levels.size()+" levels, took "+ (System.currentTimeMillis()-t01) + " ms");
long t011 = System.currentTimeMillis();
Point pnt = getLatLonIndices(lat, lon, refTime, validTime, levels.get(0).toString(),
pluginName, mdlName);
if (pnt == null) {
@ -209,7 +306,8 @@ public class MdlSoundingQuery {
return pf;
}
System.out.println("getLatLonIndices pntX=" + pnt.getX()+ " pntY=" + pnt.getY()+ " took "+ (System.currentTimeMillis()-t011) + " ms");
long t012 = System.currentTimeMillis();
List<NcSoundingLayer> layerList = getModelSoundingLayerList(pnt,
refTime, validTime, pluginName, mdlName, levels);
if (layerList.size() == 0) {
@ -220,10 +318,13 @@ public class MdlSoundingQuery {
return pf;
}
pf.setStationLatitude((float) lat);
pf.setStationLongitude((float) lon);
System.out.println("getModelSoundingLayerList= "+ layerList.size()+ " layers, took "+ (System.currentTimeMillis()-t012) + " ms");
pf.setStationLatitude( lat);
pf.setStationLongitude( lon);
Float sfcPressure = getModelSfcPressure(pnt, refTime, validTime,
pluginName, mdlName);
//System.out.println("getModelSfcPressure took "+ (System.currentTimeMillis()-t013) + " ms");
if (sfcPressure == null) {
pf.setSfcPress(-9999.f);
}
@ -235,27 +336,41 @@ public class MdlSoundingQuery {
}
//System.out.println("surface pressure ="+pf.getSfcPress()+ " lat= "+lat+ " lon="+lon);
//calculate dew point if necessary
long t014 = System.currentTimeMillis();
MergeSounding ms = new MergeSounding();
ms.spfhToDewpoint(layerList);
//ms.spfhToDewpoint(layerList);
ms.rhToDewpoint(layerList);
System.out.println("MergeSounding took "+ (System.currentTimeMillis()-t014) + " ms");
pf.setSoundingLyLst(layerList);
soundingProfileList.add(pf);
//cube.setSoundingProfileList(soundingProfileList);
//cube.setRtnStatus(NcSoundingCube.QueryStatus.OK);
long t02 = System.currentTimeMillis();
System.out.println("MDL cube retreival took " + (t02 - t01));
return pf;
}
}*/
public static NcSoundingModel getMdls(String perspectiveName) {
// TO do by M. G.
public static NcSoundingModel getMdls(String pluginName) {
NcSoundingModel mdls = new NcSoundingModel();
Object[] mdlName = null;
if (pluginName.equalsIgnoreCase(NCGRIB_TBL_NAME)) {
CoreDao dao = new CoreDao(DaoConfig.forClass(NcgribModel.class));
String queryStr = new String("Select Distinct modelname FROM ncgrib_models ORDER BY modelname");
mdlName = (Object[]) dao.executeSQLQuery(queryStr);
}
else if (pluginName.equalsIgnoreCase(D2DGRIB_TBL_NAME)) {
CoreDao dao = new CoreDao(DaoConfig.forClass(NcgribModel.class));
String queryStr = new String("Select Distinct modelname FROM grib_models ORDER BY modelname");
mdlName = (Object[]) dao.executeSQLQuery(queryStr);
}
if(mdlName!=null && mdlName.length>0){
List<String> mdlList = new ArrayList<String>();
for(Object mn : mdlName){
mdlList.add((String)mn);
}
mdls.setMdlList(mdlList);
}
return mdls;
}
@ -551,6 +666,263 @@ public class MdlSoundingQuery {
}
/**
* Returns a list of NcSoundingProfile for a group of Point with specific ref and range time, and
* model for grib or ncgrib data.
*
* @param pnt
* location
* @param pluginName
* the name of the data table ('grib' or 'ncgrib')
* @param modelName
* the name of the model
* @param levels
* list of vertical levels
* @return list of NcSoundingLayer objects
*
* Created @ 3/28/2012
*/
private static List<NcSoundingProfile> queryProfileListByPointGroup(List<Point> points,
String refTime, String validTime, String pluginName,
String modelName, List<?> levels) {
List<NcSoundingProfile> soundingProfileList = new ArrayList<NcSoundingProfile>();
List<float[]> fdataArrayList = new ArrayList<float[]>();
//long t01 = System.currentTimeMillis();
if (pluginName.equalsIgnoreCase(NCGRIB_TBL_NAME)) {
List<NcgribRecord> recList = new ArrayList<NcgribRecord>(); ;
TableQuery query;
try {
query = new TableQuery("metadata",
NcgribRecord.class.getName());
query.addParameter("vcord", "PRES");
query.addParameter("modelName", modelName);
query.addList("parm",NC_PARMS);//parmList.toString()); //
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
//query.addParameter("glevel1", level.toString());
query.setSortBy("glevel1", false);
recList = (List<NcgribRecord>) query.execute();
//System.out.println("Ncgrib group query0 result size ="+ recList.size());
if (recList.size() != 0) {
PointIn pointIn = new PointIn(pluginName, recList.get(0));
//Chin note:
// We query multiple points, and for each point, query all levels (pressure) and all parameters
//(at that level) with one shot.
// The return array list (fdataArrayList) are listed in the same order as querying list "points"
// Each element (float[]) of the returned array list, represent a Point data, contains the same number of
// parameters and listed in the same order as querying rec array (recList.toArray())
//However, returned element (float[]) does not tell you which parameter itself is.
//Therefore, we have to use information in query rec array to find out returned value's type (which parameter it is)
// Further, we have to sort and store returned values to NcSoundingLayer based on its level (pressure)
// Parameters in same level should be stored in one same NcSoundingLayer,
// NcSoundingLayers for same Point should be stored in same NcSoundingProfile.
fdataArrayList = pointIn.getHDF5GroupDataPoints(recList.toArray(),points);
}
}catch (DataAccessLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int index=0;
GridGeometry2D geom = MapUtil.getGridGeometry(spatialArea);
CoordinateReferenceSystem crs = geom.getCoordinateReferenceSystem();
Coordinate coord= new Coordinate(45,45);
for(float[] fdataArray: fdataArrayList ){
//one fdataArray is for one Point or say one profile
NcSoundingProfile pf = new NcSoundingProfile();
List<NcSoundingLayer> soundLyList = new ArrayList<NcSoundingLayer>();
Point pnt = points.get(index);
Object[] recArray = recList.toArray();
for (Object level : levels){
NcSoundingLayer soundingLy = new NcSoundingLayer();
int pressure= (Integer)level;
soundingLy.setPressure( pressure);
for (int i=0; i < recArray.length; i++) {
NcgribRecord rec1 = (NcgribRecord)recArray[i];
float fdata = fdataArray[i];
if(rec1.getGlevel1() == pressure){
String prm = rec1.getParm();
//long t01 = System.currentTimeMillis();
switch (NcParmNames.valueOf(prm)) {
case HGHT:
soundingLy.setGeoHeight(fdata);
break;
case UREL:
// HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindU((float)metersPerSecondToKnots.convert(fdata));
break;
case VREL:
// HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindV((float)metersPerSecondToKnots.convert(fdata));
break;
case TMPK:
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
break;
case DWPK:
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
break;
case SPFH:
soundingLy.setSpecHumidity(fdata);
break;
case OMEG:
soundingLy.setOmega(fdata);
break;
case RELH:
soundingLy.setRelativeHumidity(fdata);
break;
}
}
}
soundLyList.add(soundingLy);
}
try {
coord = PointUtil.determineLatLon(pnt, crs, geom);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println(" point coord.y="+coord.y+ " coord.x="+ coord.x);
pf.setStationLatitude(coord.y);
pf.setStationLongitude( coord.x);
//Float sfcPressure = getModelSfcPressure(pnt, refTime, validTime,
// pluginName, modelName);
//System.out.println("getModelSfcPressure took "+ (System.currentTimeMillis()-t013) + " ms");
//if (sfcPressure == null) {
pf.setSfcPress(-9999.f);
//}
//else {
// pf.setSfcPress(sfcPressure);
//}
//System.out.println("surface pressure ="+pf.getSfcPress());
//calculate dew point if necessary
MergeSounding ms = new MergeSounding();
//ms.spfhToDewpoint(layerList);
ms.rhToDewpoint(soundLyList);
//System.out.println("MergeSounding took "+ (System.currentTimeMillis()-t014) + " ms");
pf.setSoundingLyLst(soundLyList);
soundingProfileList.add(pf);
index++;
}
}
else if (pluginName.equalsIgnoreCase(D2DGRIB_TBL_NAME)) {
List<GribRecord> recList = new ArrayList<GribRecord>(); ;
TableQuery query;
try {
query = new TableQuery("metadata",
GribRecord.class.getName());
query.addParameter("modelInfo.level.masterLevel.name", "MB");
query.addParameter("modelInfo.modelName", modelName);
query.addList("modelInfo.parameterAbbreviation",
D2D_PARMS);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
query.setSortBy("modelInfo.level.levelonevalue", false);
recList = (List<GribRecord>) query.execute();
if (recList.size() != 0) {
PointIn pointIn = new PointIn(pluginName, recList.get(0));
fdataArrayList = pointIn.getHDF5GroupDataPoints(recList.toArray(),points);
}
}catch (DataAccessLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int index=0;
GridGeometry2D geom = MapUtil.getGridGeometry(spatialArea);
CoordinateReferenceSystem crs = geom.getCoordinateReferenceSystem();
Coordinate coord= new Coordinate(45,45);
for(float[] fdataArray: fdataArrayList ){
//one fdataArray is for one Point or say one profile
NcSoundingProfile pf = new NcSoundingProfile();
List<NcSoundingLayer> soundLyList = new ArrayList<NcSoundingLayer>();
Point pnt = points.get(index);
Object[] recArray = recList.toArray();
for (Object level : levels){
NcSoundingLayer soundingLy = new NcSoundingLayer();
double pressure= (Double)level;
soundingLy.setPressure( (float)pressure);
for (int i=0; i < recArray.length; i++) {
GribRecord rec1 = (GribRecord)recArray[i];
float fdata = fdataArray[i];
if(rec1.getModelInfo().getLevelOneValue() == pressure){
String prm = rec1.getModelInfo().getParameterAbbreviation();
switch (D2DParmNames.valueOf(prm)) {
case GH:
soundingLy.setGeoHeight(fdata);
break;
case uW:
// HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindU((float)metersPerSecondToKnots.convert(fdata));
break;
case vW:
// HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindV((float)metersPerSecondToKnots.convert(fdata));
break;
case T:
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
break;
case DWPK:
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
break;
case OMEG:
soundingLy.setOmega(fdata);
break;
case RH:
soundingLy.setRelativeHumidity(fdata);
break;
}
}
}
soundLyList.add(soundingLy);
}
try {
coord = PointUtil.determineLatLon(pnt, crs, geom);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println(" point coord.y="+coord.y+ " coord.x="+ coord.x);
pf.setStationLatitude(coord.y);
pf.setStationLongitude( coord.x);
//Float sfcPressure = getModelSfcPressure(pnt, refTime, validTime,
// pluginName, modelName);
//System.out.println("getModelSfcPressure took "+ (System.currentTimeMillis()-t013) + " ms");
///if (sfcPressure == null) {
pf.setSfcPress(-9999.f);
//}
//else {
// pf.setSfcPress(sfcPressure/100F);
//}
//System.out.println("surface pressure ="+pf.getSfcPress()+ " lat= "+lat+ " lon="+lon);
//calculate dew point if necessary
MergeSounding ms = new MergeSounding();
//ms.spfhToDewpoint(layerList);
ms.rhToDewpoint(soundLyList);
pf.setSoundingLyLst(soundLyList);
soundingProfileList.add(pf);
index++;
}
}
return soundingProfileList;
}
/**
* Returns a list of NcSoundingLayer for a specified location, time, and
* model for grib or ncgrib data.
@ -564,136 +936,89 @@ public class MdlSoundingQuery {
* @param levels
* list of vertical levels
* @return list of NcSoundingLayer objects
*/
*
private static List<NcSoundingLayer> getModelSoundingLayerList(Point pnt,
String refTime, String validTime, String pluginName,
String modelName, List<?> levels) {
// CoreDao dao = new CoreDao(DaoConfig.forClass(NcgribRecord.class));
List<NcSoundingLayer> soundLyList = new ArrayList<NcSoundingLayer>();
long t01 = System.currentTimeMillis();
StringBuilder parmList = new StringBuilder();
boolean ht, ur, vr, t, d,sh, rh, om;
//long t01 = System.currentTimeMillis();
if (pluginName.equalsIgnoreCase(NCGRIB_TBL_NAME)) {
TableQuery query;
try {
for (Object level : levels) {
NcSoundingLayer soundingLy = new NcSoundingLayer();
ht = ur= vr= t= d=sh= rh= om= false;
query = new TableQuery("metadata",
NcgribRecord.class.getName());
query.addParameter("vcord", "PRES");
query.addParameter("modelName", modelName);
query.addList("parm",NC_PARMS);//parmList.toString()); //
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
query.addParameter("glevel1", level.toString());
//query.setSortBy("glevel1", false);
//System.out.println("level = "+ level.toString());
query = new TableQuery("metadata",
NcgribRecord.class.getName());
query.addParameter("vcord", "PRES");
query.addParameter("modelName", modelName);
query.addList("parm",NC_PARMS);//parmList.toString()); //
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
//query.addParameter("glevel1", level.toString());
query.setSortBy("glevel1", false);
List<NcgribRecord> recList = (List<NcgribRecord>) query
.execute();
//System.out.println("level = "+ level.toString() + " has "+recList.size()+ " records" );
if (recList.size() != 0) {
for (NcgribRecord rec1 : recList) {
soundingLy.setPressure((float) rec1
.getGlevel1());
String prm = rec1.getParm();
//System.out.println("point.x="+ pnt.x + " .y="+pnt.y+"pressure="+rec1
// .getGlevel1());
//System.out.println("point.x="+ pnt.x + " .y="+pnt.y+"prm="+prm);
switch (NcParmNames.valueOf(prm)) {
case HGHT:
if(ht== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setGeoHeight(fdata);
ht = true;
List<NcgribRecord> recList = (List<NcgribRecord>) query.execute();
System.out.println("Ncgrib group query0 result size ="+ recList.size());
if (recList.size() != 0) {
PointIn pointIn = new PointIn(pluginName, recList.get(0),
pnt.x, pnt.y);
//Chin note:
// We query all levels (pressure) and all parameters (at that level) at once.
// The return array (fdataArray) are listed in the same order as query array (recList.toArray())
//However, returned array does not tell you which parameter itself is.
//Therefore, we have to use information in query array to find out returned value's type (which parameter it is)
// Further, we have to sort and store returned values to NcSoundingLayer based on its level (pressure)
// Parameters in same level should be stored in one same NcSoundingLayer
float[] fdataArray = pointIn.getHDF5GroupDataPoint(recList.toArray());
Object[] recArray = recList.toArray();
for (Object level : levels){
NcSoundingLayer soundingLy = new NcSoundingLayer();
int pressure= (Integer)level;
soundingLy.setPressure( pressure);
for (int i=0; i < recArray.length; i++) {
NcgribRecord rec1 = (NcgribRecord)recArray[i];
float fdata = fdataArray[i];
if(rec1.getGlevel1() == pressure){
String prm = rec1.getParm();
//System.out.println("point.x="+ pnt.x + " .y="+pnt.y+"pressure="+rec1
// .getGlevel1()+ " Parm="+prm );
//long t01 = System.currentTimeMillis();
switch (NcParmNames.valueOf(prm)) {
case HGHT:
soundingLy.setGeoHeight(fdata);
break;
case UREL:
// HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindU(fdata);
break;
case VREL:
// HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindV(fdata);
break;
case TMPK:
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
break;
case DWPK:
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
break;
case SPFH:
soundingLy.setSpecHumidity(fdata);
break;
case OMEG:
soundingLy.setOmega(fdata);
break;
case RELH:
soundingLy.setRelativeHumidity(fdata);
break;
}
break;
case UREL:
// HDF5 data in
// unit of
// Knots, no
// conversion
// needed
if(ur== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setWindU(fdata);
ur = true;
}
break;
case VREL:
// HDF5 data in
// unit of
// Knots, no
// conversion
// needed
if(vr== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setWindV(fdata);
vr = true;
}
break;
case TMPK:
if(t== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
t = true;
}
break;
case DWPK:
if(d== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
d = true;
}
break;
case SPFH:
if(sh== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setSpecHumidity(fdata);
sh = true;
}
break;
case OMEG:
if(om== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setOmega(fdata);
om = true;
}
break;
case RELH:
if(rh== false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setRelativeHumidity(fdata);
rh = true;
}
break;
}
}
soundLyList.add(soundingLy);
}
@ -706,149 +1031,99 @@ public class MdlSoundingQuery {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println("getModelSoundingLayerList:total level = "+ totalLevel + " total records= "+totalRecords );
}
else if (pluginName.equalsIgnoreCase(D2DGRIB_TBL_NAME)) {
try {
TableQuery query = new TableQuery("metadata",
GribRecord.class.getName());
//query.addParameter("modelInfo.level.levelonevalue",
// level.toString());
//query.addParameter("modelInfo.level.leveltwovalue",
// "-999999.0");
query.addParameter("modelInfo.level.masterLevel.name", "MB");
query.addParameter("modelInfo.modelName", modelName);
query.addList("modelInfo.parameterAbbreviation",
D2D_PARMS);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
query.setSortBy("modelInfo.level.levelonevalue", false);
//System.out.println("level = "+ level.toString());
for (Object level : levels) {
ht = ur= vr= t= d=sh= rh= om= false;
NcSoundingLayer soundingLy = new NcSoundingLayer();
try {
//Chin should change for performance
TableQuery query = new TableQuery("metadata",
GribRecord.class.getName());
query.addParameter("modelInfo.level.levelonevalue",
level.toString());
query.addParameter("modelInfo.level.leveltwovalue",
"-999999.0");
query.addParameter("modelInfo.level.masterLevel.name", "MB");
query.addParameter("modelInfo.modelName", modelName);
query.addList("modelInfo.parameterAbbreviation",
D2D_PARMS);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
query.setSortBy("modelInfo.level.levelonevalue", false);
//System.out.println("level = "+ level.toString());
try {
List<GribRecord> recList = (List<GribRecord>) query
.execute();
if (recList.size() != 0) {
for (GribRecord rec1 : recList) {
soundingLy.setPressure((float) rec1
.getModelInfo().getLevel()
.getLevelonevalue());
String prm = rec1.getModelInfo()
.getParameterAbbreviation();
List<GribRecord> recList = (List<GribRecord>) query.execute();
System.out.println("Grib group query0 result size ="+ recList.size());
//System.out.println("point.x="+ pnt.x + " .y="+pnt.y+"prm="+prm+" value="+fdata);
if (recList.size() > 0) {
PointIn pointIn = new PointIn(pluginName, recList.get(0),
pnt.x, pnt.y);
float[] fdataArray = pointIn.getHDF5GroupDataPoint(recList.toArray());
Object[] recArray = recList.toArray();
for (Object level : levels){
NcSoundingLayer soundingLy = new NcSoundingLayer();
double pressure= (Double)level;
soundingLy.setPressure( (float)pressure);
for (int i=0; i < recArray.length; i++) {
GribRecord rec1 = (GribRecord)recArray[i];
float fdata = fdataArray[i];
if(rec1.getModelInfo().getLevelOneValue() == pressure){
String prm = rec1.getModelInfo().getParameterAbbreviation();
//System.out.println("point.x="+ pnt.x + " .y="+pnt.y+"pressure="+pressure+ " Parm="+prm );
//long t01 = System.currentTimeMillis();
switch (D2DParmNames.valueOf(prm)) {
case GH:
if(ht == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setGeoHeight(fdata);
ht= true;
}
soundingLy.setGeoHeight(fdata);
break;
case uW:
// HDF5 data in
// unit of
// Knots, no
// conversion
// needed
if(ur == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setWindU(fdata);
ur= true;
}
// HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindU(fdata);
break;
case vW:
// HDF5 data in
// unit of
// Knots, no
// conversion
// needed
if(vr == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setWindV(fdata);
vr= true;
}
// HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindV(fdata);
break;
case T:
if(t == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
t= true;
}
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
break;
case DWPK:
if(d == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
d= true;
}
break;
case RH:
if(rh == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setRelativeHumidity(fdata);
rh= true;
}
case DWPK:
soundingLy.setDewpoint((float) kelvinToCelsius
.convert(fdata));
break;
case OMEG:
if(om == false){
PointIn pointIn = new PointIn(pluginName, rec1,
pnt.x, pnt.y);
float fdata = pointIn.getPointData();
soundingLy.setOmega(fdata);
om= true;
}
soundingLy.setOmega(fdata);
break;
case RH:
soundingLy.setRelativeHumidity(fdata);
break;
}
}
soundLyList.add(soundingLy);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
soundLyList.add(soundingLy);
}
} catch (DataAccessLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch (DataAccessLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
long t02 = System.currentTimeMillis();
//long t02 = System.currentTimeMillis();
//System.out.println("MDL profile retreival took " + (t02 - t01));
/*/debug
for(NcSoundingLayer layer: soundLyList){
System.out.println("pre="+ layer.getPressure()+ " h="+layer.getGeoHeight()+ " T="+layer.getTemperature()+" D="+
layer.getDewpoint()+ " WS="+layer.getWindSpeed()+ " WD="+layer.getWindDirection() + " SH="+layer.getSpecHumidity()+ " RH="+layer.getRelativeHumidity());
}*/
}
return soundLyList;
}
*/
/**
* Return a list of data vertical levels for a specified time and model for
* grib or ncgrib data.
@ -909,7 +1184,7 @@ public class MdlSoundingQuery {
return null;
}
private static ISpatialObject spatialArea = null;
/**
* Returns the indices of the model grid of the closest point to the
* specified latitude, longitude.
@ -929,7 +1204,7 @@ public class MdlSoundingQuery {
public static Point getLatLonIndices(double lat, double lon,
String refTime, String validTime, String level, String pluginName,
String modelName) {
ISpatialObject spatialArea = null;
//ISpatialObject spatialArea = null;
Point pnt = null;

View file

@ -28,6 +28,7 @@ import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer2;
* 11/15/2010 301 C. Chen fix a index out of bound bug
* 12/2010 301 T. Lee/NCEP Re-factored for BUFRUA
* 5/10/2011 301 C. Chen added rhToDewpoint(), tempToVapr()
* 02/28/2012 Chin Chen modify several sounding query algorithms for better performance
* </pre>
*
* @author T. Lee
@ -93,9 +94,9 @@ public class MergeSounding {
if ( ttaa.size() > 0 ) {
Collections.sort(ttaa, new reverseSortByPressure());
//System.out.println("TTAA sounding: ");
for ( NcSoundingLayer soundLy : ttaa ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ttaa ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
if (level.toUpperCase().equalsIgnoreCase("MAN")) {
return ttaa;
@ -116,27 +117,27 @@ public class MergeSounding {
if ( ttbb.size() > 0) {
Collections.sort(ttbb, new reverseSortByPressure());
//System.out.println("TTBB sounding: ");
for ( NcSoundingLayer soundLy : ttbb ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ttbb ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
if ( ttcc.size() > 0) {
Collections.sort(ttcc, new reverseSortByPressure());
//System.out.println("TTCC sounding: ");
for ( NcSoundingLayer soundLy : ttcc ){
System.out.print(soundLy.getPressure() + " , ");
}
////for ( NcSoundingLayer soundLy : ttcc ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
if ( ttdd.size() > 0) {
Collections.sort(ttdd, new reverseSortByPressure());
//System.out.println("TTDD sounding: ");
for ( NcSoundingLayer soundLy : ttdd ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ttdd ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
@ -144,16 +145,16 @@ public class MergeSounding {
if (checkWindData(ppaa)) {
Collections.sort(ppaa, new MergeSounding.sortByHeight());
//System.out.println("TTAA sounding: ");
for ( NcSoundingLayer soundLy : ttaa ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ttaa ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
} else {
Collections.sort(ppaa, new MergeSounding.reverseSortByPressure());
//System.out.println("TTAA sounding: ");
for ( NcSoundingLayer soundLy : ttaa ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ttaa ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
}
@ -163,16 +164,16 @@ public class MergeSounding {
if (checkWindData(ppcc)) {
Collections.sort(ppcc, new MergeSounding.sortByHeight());
//System.out.println("PPCC sounding: ");
for ( NcSoundingLayer soundLy : ppcc ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppcc ){
// System.out.print(soundLy.getPressure() + " , ");
// }
//System.out.println();
} else {
Collections.sort(ppcc, new MergeSounding.reverseSortByPressure());
//System.out.println("PPCC sounding: ");
for ( NcSoundingLayer soundLy : ppcc ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppcc ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
}
@ -181,16 +182,16 @@ public class MergeSounding {
if (checkWindData(ppbb)) {
Collections.sort(ppbb, new MergeSounding.sortByHeight());
//System.out.println("PPBB sounding: ");
for ( NcSoundingLayer soundLy : ppbb ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppbb ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
} else {
Collections.sort(ppbb, new MergeSounding.reverseSortByPressure());
//System.out.println("PPBB sounding: ");
for ( NcSoundingLayer soundLy : ppbb ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppbb ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}
}
@ -200,16 +201,16 @@ public class MergeSounding {
if (checkWindData(ppdd)) {
Collections.sort(ppdd, new MergeSounding.sortByHeight());
//System.out.println("PPDD sounding: ");
for ( NcSoundingLayer soundLy : ppdd ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppdd ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
} else {
Collections.sort(ppdd, new MergeSounding.reverseSortByPressure());
//System.out.println("PPDD sounding: ");
for ( NcSoundingLayer soundLy : ppdd ){
System.out.print(soundLy.getPressure() + " , ");
}
//for ( NcSoundingLayer soundLy : ppdd ){
// System.out.print(soundLy.getPressure() + " , ");
//}
//System.out.println();
}

View file

@ -49,7 +49,9 @@ import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer2;
* 10/06/2011 465 Archana redesigned the merge sounding to use
* the met parameters
* 10/24/2011 465 Archana Removed several debug statements.
* Used the Amount class to set values for the Met parameters
* Used the Amount class to set values for the Met parameters
* 02/22/2012 C Chen fixed minor bugs
* 02/28/2012 Chin Chen modify several sounding query algorithms for better performance
*
* </pre>
*
@ -406,6 +408,7 @@ public class MergeSounding2 implements ISerializableObject {
DewPointTemp dewPoint;
try {
dewPoint = new DewPointTemp();
dewPoint.setValue( new Amount ( dwpc, SI.CELSIUS ) );
layer.setDewpoint( dewPoint);
} catch (Exception e1) {
// TODO Auto-generated catch block
@ -450,7 +453,7 @@ public class MergeSounding2 implements ISerializableObject {
else {
dwpc = (float) (243.5 * ( Math.log(6.112) - Math.log(vapr)) /
(Math.log(vapr) - Math.log(6.112)-17.67));
dewpoint.setValueAs(dwpc, "" );
dewpoint.setValue( new Amount ( dwpc, SI.CELSIUS ));
layer.setDewpoint( dewpoint );
////System.out.println("rhToDewpoint dwpc: " + dwpc);
}

View file

@ -13,7 +13,8 @@ package gov.noaa.nws.ncep.edex.uengine.tasks.profile;
* ------- ------- -------- -----------
* 09/13/2010 301 Chin Chen Initial coding
* 12/16/2010 301 Chin Chen add support of PFC (NAM and GFS) model sounding data
*
* 02/28/2012 Chin Chen modify several sounding query algorithms for better performance
* *
* </pre>
*
* @author Chin Chen
@ -28,42 +29,31 @@ import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile.PfcSndType;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile.SndQueryKeyType;
import java.io.File;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import com.raytheon.edex.plugin.modelsounding.common.ModelSoundingPointDataTransform;
import com.raytheon.edex.plugin.modelsounding.common.SoundingLevel;
import com.raytheon.edex.plugin.modelsounding.common.SoundingSite;
import com.raytheon.edex.plugin.modelsounding.dao.ModelSoundingDAO;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.LongDataRecord;
import com.raytheon.uf.common.datastorage.records.StringDataRecord;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.vividsolutions.jts.geom.Coordinate;
public class PfcSoundingQuery {
private static final String PFC_TBL_NAME = "modelsounding";
private static String currentDBTblName = "nil";
private static String reportType;
public static UnitConverter kelvinToCelsius = SI.KELVIN.getConverterTo(SI.CELSIUS);
public static NcSoundingStnInfoCollection getPfcSndStnInfoCol(String sndType, String selectedSndTime) {
private static UnitConverter kelvinToCelsius = SI.KELVIN.getConverterTo(SI.CELSIUS);
private static UnitConverter metersPerSecondToKnots = SI.METERS_PER_SECOND.getConverterTo(NonSI.KNOT);
public static NcSoundingStnInfoCollection getPfcSndStnInfoCol(String sndType, String selectedSndTime, String refTimeStr) {
NcSoundingStnInfoCollection stnInfoCol = new NcSoundingStnInfoCollection();
List<NcSoundingStnInfo> stationInfoList= new ArrayList<NcSoundingStnInfo>();
String queryStr="";
@ -80,7 +70,7 @@ public class PfcSoundingQuery {
return stnInfoCol;
}
queryStr = new String("Select Distinct latitude, longitude, stationid, elevation, reftime, rangestart FROM "+ currentDBTblName + " where rangestart='" +
selectedSndTime+ "' AND reporttype ='" + reportType + "' AND latitude BETWEEN -89.9 AND 89.9 AND longitude BETWEEN -179.9 AND 179.9");
selectedSndTime+ "' AND reftime ='"+ refTimeStr+ "' AND reporttype ='" + reportType + "' AND latitude BETWEEN -89.9 AND 89.9 AND longitude BETWEEN -179.9 AND 179.9");
//System.out.println(queryStr);
CoreDao dao = new CoreDao(DaoConfig.forClass(SoundingSite.class));
@ -100,8 +90,8 @@ public class PfcSoundingQuery {
NcSoundingStnInfo stn = stnInfoCol.getNewStnInfo();
stn.setStnId((String)objArray[2]);
stn.setStationLongitude((float)lon);
stn.setStationLatitude((float)lat);
stn.setStationLongitude(lon);
stn.setStationLatitude(lat);
stn.setStationElevation((float)elv);
stn.setSynopTime((Timestamp)objArray[4]);
stn.setRangeStartTime((Timestamp)objArray[5]);
@ -155,7 +145,7 @@ public class PfcSoundingQuery {
}
//query table in metadata db
String queryStr = new String("Select Distinct rangestart FROM "+ currentDBTblName +
" where reporttype='" +reportType+ "' AND "+ "reftime='"+refTimeStr+":00:00'"+" ORDER BY rangestart DESC");
" where reporttype='" +reportType+ "' AND "+ "reftime='"+refTimeStr+":00:00'"+" ORDER BY rangestart");// DESC");
System.out.println("queryStr "+ queryStr);
@ -165,7 +155,9 @@ public class PfcSoundingQuery {
return tl;
}
/*
* Chin Note: 02/27/12 obsoleting this one. Use getPfcSndDataGeneric()
*
public static NcSoundingProfile getPfcSndData(double lat, double lon, String stn, long refTimeL, long validTimeL, String sndTypeStr, SndQueryKeyType queryType) {
//*System.out.println("getPfcSndData input ref time = "+ refTimeL+" valid time is " + validTimeL);
Calendar refTimeCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
@ -174,7 +166,10 @@ public class PfcSoundingQuery {
validTimeCal.setTimeInMillis(validTimeL);
return getPfcSndData( lat, lon, stn, refTimeCal, validTimeCal, sndTypeStr, queryType);
}
*/
/*
* Chin Note: 02/27/12 obsoleting this one. Use getPfcSndDataGeneric()
*
@SuppressWarnings("unchecked")
public static NcSoundingProfile getPfcSndData(double lat, double lon, String stn, Calendar refTimeCal, Calendar validTimeCal, String sndTypeStr, SndQueryKeyType queryType) {
//System.out.println("getPfcSndData input ref time = "+ refTimeCal+" valid time is " + validTimeCal);
@ -239,8 +234,8 @@ public class PfcSoundingQuery {
//for(SoundingSite site: lSndSiteRecords)
// System.out.println("SoundingSite record Idx="+ site.getIdx());
//set pf data
pf.setStationLatitude((float)lSndSiteRecords.get(0).getLatitude());
pf.setStationLongitude((float)lSndSiteRecords.get(0).getLongitude());
pf.setStationLatitude(lSndSiteRecords.get(0).getLatitude());
pf.setStationLongitude(lSndSiteRecords.get(0).getLongitude());
pf.setStationElevation((float)lSndSiteRecords.get(0).getElevation());
if(lSndSiteRecords.get(0).getSiteId()!=null && lSndSiteRecords.get(0).getSiteId().length()>0)
pf.setStationNum(Integer.parseInt(lSndSiteRecords.get(0).getSiteId()));
@ -287,7 +282,7 @@ public class PfcSoundingQuery {
//ModelSoundingDAO mdldao = new ModelSoundingDAO("modelsounding");
//File hdf5loc = mdldao.getFullFilePath(lSndSiteRecords.get(0));
//*System.out.println("hdf5 path = " + hdf5loc.getAbsolutePath());
//System.out.println("hdf5 path = " + hdf5loc.getAbsolutePath());
//IDataStore dataStore = DataStoreFactory.getDataStore(hdf5loc);
FloatDataRecord sfcPressurefloatData = (FloatDataRecord) dataStore.retrieve(
@ -356,216 +351,25 @@ public class PfcSoundingQuery {
}
}
/*
SoundingSite sndSite = new SoundingSite();
sndSite.setPluginName("modelsounding");
DataTime refTimeDataTime = new DataTime(refTimeCal);
sndSite.setDataTime(refTimeDataTime);
ModelSoundingDAO mdldao = new ModelSoundingDAO("modelsounding");
File hdf5loc = mdldao.getFullFilePath(sndSite);
//*System.out.println("hdf5 path = " + hdf5loc.getAbsolutePath());
IDataStore dataStore = DataStoreFactory.getDataStore(hdf5loc);
try {
LongDataRecord validtimeLongData = (LongDataRecord) dataStore.retrieve(
"/", "validTime", Request.ALL);
long[] validtimedata = validtimeLongData.getLongData();
FloatDataRecord latfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "latitude", Request.ALL);
float[] latdata = latfloatData.getFloatData();
FloatDataRecord lonfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "longitude", Request.ALL);
float[] londata = lonfloatData.getFloatData();
FloatDataRecord elvfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "elevation", Request.ALL);
float[] elvdata = elvfloatData.getFloatData();
int selectedTimeIndex=-1;
for (int j=0; j<validtimedata.length; j++)
{
//find the index of user picked data time line and lat/lon
if(( queryType.equals(SndQueryKeyType.LATLON.toString())&&
(validtimedata[j] == validTimeL/1000) &&
(latdata[j] ==(float) lat) &&
(londata[j] == (float)lon) )
||
( queryType.equals(SndQueryKeyType.STNID.toString())&&
(validtimedata[j] == validTimeL/1000) &&
(latdata[j] ==(float) lat) &&
(londata[j] == (float)lon) )
||
( queryType.equals(SndQueryKeyType.STNNUM.toString())&&
(validtimedata[j] == validTimeL/1000) &&
(latdata[j] ==(float) lat) &&
(londata[j] == (float)lon) )
)
{
selectedTimeIndex = j;
pf.setStationLatitude(latdata[j]);
pf.setStationLongitude(londata[j]);
pf.setStationElevation(elvdata[j]);
break;
}
}
if(selectedTimeIndex != -1) {
NcSoundingLayer soundingLy;
// get temp, dew point, pressure, wind u/v components, specHum, omega
FloatDataRecord omegafloatData = (FloatDataRecord) dataStore.retrieve(
"/", "omega", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] omegadata = omegafloatData.getFloatData();
long[] sizes = omegafloatData.getSizes();
//int dim = omegafloatData.getDimension();
FloatDataRecord pressurefloatData = (FloatDataRecord) dataStore.retrieve(
"/", "pressure", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] pressuredata = pressurefloatData.getFloatData();
FloatDataRecord temperaturefloatData = (FloatDataRecord) dataStore.retrieve(
"/", "temperature", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] temperaturedata = temperaturefloatData.getFloatData();
FloatDataRecord specHumfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "specHum", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] specHumdata = specHumfloatData.getFloatData();
FloatDataRecord vCompfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "vComp", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] vCompdata = vCompfloatData.getFloatData();
FloatDataRecord uCompfloatData = (FloatDataRecord) dataStore.retrieve(
"/", "uComp", Request.buildYLineRequest(new int[] {selectedTimeIndex}));
float[] uCompdata = uCompfloatData.getFloatData();
for (int i=0; i<sizes[0]; i++)
{
soundingLy = new NcSoundingLayer();
soundingLy.setOmega(omegadata[i]);
soundingLy.setTemperature((float)kelvinToCelsius.convert(temperaturedata[i]));
soundingLy.setPressure(pressuredata[i]/100F);
soundingLy.setWindU(uCompdata[i]);
soundingLy.setWindV(vCompdata[i]);
soundingLy.setSpecHumidity(specHumdata[i]);
soundLyList.add(soundingLy);
}
//*System.out.println("sounding layer size = "+ soundLyList.size());
//debug
for(NcSoundingLayer ly: soundLyList){
//*System.out.println("P= "+ly.getPressure()+ " Hm= "+ ly.getSpecHumidity()+ " T= "+ ly.getTemperature());
}
}
} catch (Exception e) {
//*System.out.println("exception=" + e );
e.printStackTrace();
}
} catch (PluginException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
pf.setSoundingLyLst(soundLyList);
}*/
//IHDFFilePathProvider pathProvider = sndSite.getHDFPathProvider();
//File hdf5loc = HDF5Util.findHDF5Location(sndSite);
//IDataStore dataStore = DataStoreFactory.getDataStore(hdf5loc);
/*
//readH5FileTest("/usr1/cchen/to11dr11/awips/edex/data/hdf5/modelsounding/2010/06/15/06/modelsounding-0.h5");
String hdf5File ="/usr1/cchen/to11dr11/awips/edex/data/hdf5/modelsounding/2010/06/15/06/modelsounding-0.h5";
//String group = sndSite.getDataURI();
String dataset = "omega";//TBD
IDataRecord dr;
int file_id = -1;
int dataset_id = -1;
float[][] dset_data = new float[182][64];
// Open file using the default properties.
try {
file_id = H5.H5Fopen(hdf5File, HDF5Constants.H5F_ACC_RDONLY,
HDF5Constants.H5P_DEFAULT);
}
catch (Exception e) {
e.printStackTrace();
}
// Open dataset using the default properties.
try {
if (file_id >= 0)
dataset_id = H5.H5Dopen(file_id, dataset);
}
catch (Exception e) {
e.printStackTrace();
}
// Read the data using the default properties.
try {
if (dataset_id >= 0)
H5.H5Dread(dataset_id, HDF5Constants.H5T_FLOAT,
HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, dset_data);
}
catch (Exception e) {
e.printStackTrace();
}
// Output the data to the screen.
System.out.println(dataset + ":");
for (int indx = 0; indx < 182; indx++) {
System.out.print(" [ ");
for (int jndx = 0; jndx < 64; jndx++)
System.out.print(dset_data[indx][jndx] + " ");
System.out.println("]");
}
System.out.println();
// Close the dataset.
try {
if (dataset_id >= 0)
H5.H5Dclose(dataset_id);
}
catch (Exception e) {
e.printStackTrace();
}
try {
if (file_id >= 0)
H5.H5Fclose(file_id);
}
catch (Exception e) {
e.printStackTrace();
}
*/
pf.setSoundingLyLst(soundLyList);
long t02 = System.currentTimeMillis();
System.out.println("PFC profile retreival took " + (t02 - t01));
return pf;
}
*/
//@SuppressWarnings("unchecked")
/*
* Chin: using ModelSoundingPointDataTransform for query. Need test after 11.5
* Chin: using ModelSoundingPointDataTransform for query.
*/
public static NcSoundingProfile getPfcSndData2(double lat, double lon, String stn, Calendar refTimeCal, Calendar validTimeCal, String sndTypeStr, SndQueryKeyType queryType) {
//System.out.println("getPfcSndData lat="+lat+" lon="+lon);
//NcSoundingProfile.PfcSndType sndType; //yes, it is not used now..
//Timestamp validTime = new Timestamp(validTimeL);
//System.out.println("getPfcSndData input ref time = "+ refTime.toGMTString()+" valid time is " + validTime.toGMTString());
long t01 = System.currentTimeMillis();
//System.out.println("getPfcSndData2 input ref time = "+ refTimeCal.getTime());
//long t01 = System.currentTimeMillis();
NcSoundingProfile pf = new NcSoundingProfile();
if(validTimeCal == null || refTimeCal == null )
return pf;
@ -612,9 +416,21 @@ public class PfcSoundingQuery {
fields.add("dataTime.validPeriod.start");// the rangeStart field name defined in SoundingSite and decoded modelsounding table
values.add(validTimeCal.getTime()); //rangestart data type defined in SoundingSite is "Date"
operands.add("=");
//for (int i=0; i < fields.size(); i++) {
// System.out.println("field "+ fields.get(i) + " value "+ values.get(i));
//String d="";
//String d1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(validTimeCal.getTime());
//d = d+d1;
//for (int i=1; i< 85; i++){
// Date date2 = new Date(validTimeCal.getTimeInMillis()-3600000*i);
// String d2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date2);
// d = d+","+d2;
//}
//values.add(d); //rangestart data type defined in SoundingSite is "Date"
//operands.add("in");
for (int i=0; i < fields.size(); i++) {
System.out.println("field "+ fields.get(i) + " value "+ values.get(i));
}
List<String> parameters = new ArrayList<String>(12);
parameters.addAll(ModelSoundingPointDataTransform.LVL_PARAMETERS);
parameters.add(ModelSoundingPointDataTransform.P_LATITUDE);
@ -622,16 +438,16 @@ public class PfcSoundingQuery {
parameters.add(ModelSoundingPointDataTransform.P_ELEVATION);
parameters.add(ModelSoundingPointDataTransform.P_STATION_ID);
parameters.add(ModelSoundingPointDataTransform.P_STATION_NUMBER);
parameters.add(ModelSoundingPointDataTransform.P_DATAURI);
try {
lSndSiteRecords = ModelSoundingPointDataTransform.getSoundingSites(fields, values, operands, parameters);
System.out.println("sounding site record size = "+ lSndSiteRecords.size());
if(lSndSiteRecords.size() > 0){
//set pf data
pf.setStationLatitude((float)lSndSiteRecords.get(0).getLatitude());
pf.setStationLongitude((float)lSndSiteRecords.get(0).getLongitude());
pf.setStationLatitude(lSndSiteRecords.get(0).getLatitude());
pf.setStationLongitude(lSndSiteRecords.get(0).getLongitude());
pf.setStationElevation((float)lSndSiteRecords.get(0).getElevation());
if(lSndSiteRecords.get(0).getSiteId()!=null && lSndSiteRecords.get(0).getSiteId().length()>0)
pf.setStationNum(Integer.parseInt(lSndSiteRecords.get(0).getSiteId()));
@ -647,17 +463,20 @@ public class PfcSoundingQuery {
soundingLy.setOmega(level.getOmega().floatValue());
soundingLy.setTemperature((float)kelvinToCelsius.convert(level.getTemperature()));
soundingLy.setPressure(level.getPressure().floatValue()/100);
soundingLy.setWindU(level.getUcWind().floatValue()); // HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindV(level.getVcWind().floatValue());
soundingLy.setWindU((float)metersPerSecondToKnots.convert(level.getUcWind().floatValue())); // HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindV((float)metersPerSecondToKnots.convert(level.getVcWind().floatValue()));
soundingLy.setSpecHumidity(level.getSpecificHumidity().floatValue());
soundLyList.add(soundingLy);
}
//System.out.println("sounding layer size = "+ soundLyList.size());
//debug
//for(NcSoundingLayer ly: soundLyList){
//*System.out.println("P= "+ly.getPressure()+ " Hm= "+ ly.getSpecHumidity()+ " T= "+ ly.getTemperature());
//for(NcSoundingLayer ly: soundLyList1){
// System.out.println("P= "+ly.getPressure()+ " Hm= "+ ly.getSpecHumidity()+ " T= "+ ly.getTemperature());
//}
for(int i =0; i<lSndSiteRecords.size();i++){
System.out.println("sounding Data uri = "+ lSndSiteRecords.get(i).getDataURI());
}
}
else
@ -681,6 +500,150 @@ public class PfcSoundingQuery {
//long t02 = System.currentTimeMillis();
//System.out.println("getPfcSndData2 PFC profile retreival took " + (t02 - t01));
return pf;
}
/*
* getPfcSndDataGeneric()
* Chin:2012-2-17
* using ModelSoundingPointDataTransform for query.
* Using Lat/lon array OR StnId array, AND soundingTimeAry (fcst time array) as input.
* This function is to be generic for all cases.
* One and only one of latLonArray and stnIdArr should be not null and the other one should be null
* soundingTimeAry should be not null
*
*/
public static List<NcSoundingProfile> getPfcSndDataGeneric(Coordinate[] coordinateArray,String[] stnIdArr, String refTimeStr,List<String> soundingTimeAry, String sndTypeStr, String level) {
List<NcSoundingProfile> pfs = new ArrayList<NcSoundingProfile>();
if(sndTypeStr.equals(PfcSndType.GFSSND.toString()) || sndTypeStr.equals(PfcSndType.NAMSND.toString())){
List<String> fields = new ArrayList<String>();
List<Object> values = new ArrayList<Object>();
List<SoundingSite> lSndSiteRecords = null;
List<String> operands = new ArrayList<String>();
MergeSounding ms = new MergeSounding();
if(coordinateArray != null){
String latStr="", lonStr="";
for ( int i=0; i < coordinateArray.length ; i++)
{
latStr = latStr+String.valueOf(coordinateArray[i].y)+",";
lonStr = lonStr+String.valueOf(coordinateArray[i].x)+",";
}
latStr=latStr.substring(0, latStr.length()-1);//get rid of last ","
lonStr=lonStr.substring(0, lonStr.length()-1);//get rid of last ","
fields.add("location.latitude");
values.add(latStr);
operands.add("in");
fields.add("location.longitude");
values.add(lonStr);
operands.add("in");
}
else if(stnIdArr != null){
fields.add("location.stationId");// the rangeStart field name defined in SoundingSite and decoded modelsounding table
String stnIdStr="";
for (String stnStr: stnIdArr){
stnIdStr = stnIdStr+stnStr;
stnIdStr= stnIdStr+",";
}
stnIdStr=stnIdStr.substring(0, stnIdStr.length()-1);//get rid of last ","
values.add(stnIdStr); //rangestart data type defined in SoundingSite is "Date"
operands.add("in");
}
else {
return pfs;
}
fields.add("dataTime.refTime");// the refTime time field name defined in SoundingSite and decoded modelsounding table
values.add(refTimeStr); //refTime data type defined in SoundingSite is "Date"
operands.add("=");
// the rangeStart field name defined in SoundingSite and decoded modelsounding table. It is forcast time.
fields.add("dataTime.validPeriod.start");
String d="";
for (String timeStr: soundingTimeAry){
d = d+timeStr;
d= d+",";
}
d=d.substring(0, d.length()-1);//get rid of last ","
values.add(d); //rangestart data type defined in SoundingSite is "Date"
operands.add("in");
for (int i=0; i < fields.size(); i++) {
System.out.println("getPfcSndDataGeneric: field ="+ fields.get(i) + " value= "+ values.get(i) + " operand= "+operands.get(i));
}
List<String> parameters = new ArrayList<String>(12);
parameters.addAll(ModelSoundingPointDataTransform.LVL_PARAMETERS);
parameters.add(ModelSoundingPointDataTransform.P_LATITUDE);
parameters.add(ModelSoundingPointDataTransform.P_LONGITUDE);
parameters.add(ModelSoundingPointDataTransform.P_ELEVATION);
parameters.add(ModelSoundingPointDataTransform.P_STATION_ID);
parameters.add(ModelSoundingPointDataTransform.P_STATION_NUMBER);
parameters.add(ModelSoundingPointDataTransform.P_REF_TIME);
parameters.add(ModelSoundingPointDataTransform.P_FORECAST_HOUR);
try {
long t01 = System.currentTimeMillis();
lSndSiteRecords = ModelSoundingPointDataTransform.getSoundingSites(fields, values, operands, parameters);
long t02 = System.currentTimeMillis();
System.out.println("getPfcSndDataGeneric sounding site record size = "+ lSndSiteRecords.size()+
" took "+(t02-t01)+ " ms");
for(SoundingSite sndSite:lSndSiteRecords){
//set pf data
NcSoundingProfile pf = new NcSoundingProfile();
pf.setStationLatitude(sndSite.getLatitude());
pf.setStationLongitude(sndSite.getLongitude());
pf.setStationElevation((float)sndSite.getElevation());
pf.setFcsTime((sndSite.getDataTime().getFcstTime()*1000)+ sndSite.getDataTime().getRefTime().getTime());
if(sndSite.getSiteId()!=null && sndSite.getSiteId().length()>0)
pf.setStationNum(Integer.parseInt(sndSite.getSiteId()));
pf.setStationId(sndSite.getStationId());
List<NcSoundingLayer> soundLyList = new ArrayList<NcSoundingLayer>();
//for (int i=0; i<sizes[0]; i++)
for (SoundingLevel sndLevel : sndSite.getLevels())
{
NcSoundingLayer soundingLy = new NcSoundingLayer();
soundingLy.setOmega(sndLevel.getOmega().floatValue());
soundingLy.setTemperature((float)kelvinToCelsius.convert(sndLevel.getTemperature()));
soundingLy.setPressure(sndLevel.getPressure().floatValue()/100);
soundingLy.setWindU((float)metersPerSecondToKnots.convert(sndLevel.getUcWind().floatValue())); // HDF5 data in unit of m/s, convert to Knots 4/12/2012
soundingLy.setWindV((float)metersPerSecondToKnots.convert(sndLevel.getVcWind().floatValue()));
soundingLy.setSpecHumidity(sndLevel.getSpecificHumidity().floatValue());
soundLyList.add(soundingLy);
}
Collections.sort(soundLyList,reversePressureComparator());
pf.setSoundingLyLst(soundLyList);
ms.nativeModelSounding(pf.getSoundingLyLst(), pf.getStationElevation());
if ( ms.isNumber (level) == 0 ) {
//level is an integer >=0. It means user request a single level
float rlev = new Integer(Integer.parseInt(level.trim())).floatValue();
pf.setSoundingLyLst(ms.getSingLevel(rlev, pf.getSoundingLyLst()));
} else if ( ms.isNumber (level) == 1 ) {
//level is an float >=0. It also means user request a single level
float rlev = new Float(Float.parseFloat(level.trim()));
pf.setSoundingLyLst(ms.getSingLevel(rlev, pf.getSoundingLyLst()));
}
pfs.add(pf);
//System.out.println("sounding fcs time = "+ pf.getFcsTime());
//System.out.println("sounding ref time = "+ sndSite.getDataTime().getRefTime().getTime());
}
} catch (Exception e) {
//System.out.println("exception=" + e );
e.printStackTrace();
return pfs;
}
}
//debug
//long t02 = System.currentTimeMillis();
//System.out.println("getPfcSndData2 PFC profile retreival took " + (t02 - t01));
return pfs;
}
private static Comparator<NcSoundingLayer> reversePressureComparator() {
@ -773,4 +736,136 @@ public class PfcSoundingQuery {
}
*/
/*
*
* Chin: using ModelSoundingPointDataTransform for query.
* Sounding time array is an array of user picked PFC sounding time String(s) in this format "2012-02-11 12:00:00"
* Replaced by getPfcSndDataGeneric()
*
public static List<NcSoundingProfile> getPfcSndDataBySoundTimeRangeArray(double lat, double lon, String stn, String refTimeStr, List<String> soundingTimeAry, String sndTypeStr, SndQueryKeyType queryType) {
//System.out.println("getPfcSndData lat="+lat+" lon="+lon);
//NcSoundingProfile.PfcSndType sndType; //yes, it is not used now..
//Timestamp validTime = new Timestamp(validTimeL);
List<NcSoundingProfile> pfs = new ArrayList<NcSoundingProfile>();
if(sndTypeStr.equals(PfcSndType.GFSSND.toString()) || sndTypeStr.equals(PfcSndType.NAMSND.toString())){
List<String> fields = new ArrayList<String>();
List<Object> values = new ArrayList<Object>();
List<SoundingSite> lSndSiteRecords = null;
List<String> operands = new ArrayList<String>();
if(queryType==SndQueryKeyType.STNID){
fields.add("location.stationId");// the location.stationId String field name defined in SoundingSite class and decoded modelsounding table.
values.add(stn);
operands.add("=");
}
else if(queryType==SndQueryKeyType.STNNUM){
fields.add("siteid");// the siteid String field name defined in SoundingSite class and decoded in modelsounding table.
values.add(stn);
operands.add("=");
}
else if(queryType==SndQueryKeyType.LATLON){
//fields.add("location.latitude");// the location.latitude field name defined in SoundingSite class and decoded modelsounding table
//values.add(lat-0.1);
//operands.add(">=");
//fields.add("location.latitude");// the location.latitude field name defined in SoundingSite class and decoded modelsounding table
//values.add(lat+0.1);
//operands.add("<=");
//fields.add("location.longitude");// the location.longitude field name defined in SoundingSite class and decoded modelsounding table
//values.add(lon-0.1);
//operands.add(">=");
//fields.add("location.longitude");// the location.longitude field name defined in SoundingSite class and decoded modelsounding table
//values.add(lon+0.1);
//operands.add("<=");
fields.add("location.latitude");// the location.latitude field name defined in SoundingSite class and decoded modelsounding table
values.add(lat);
operands.add("=");
fields.add("location.longitude");// the location.longitude field name defined in SoundingSite class and decoded modelsounding table
values.add(lon);
operands.add("=");
}
else {
System.out.println("request query type "+ queryType+ " is not supported in this API" );
return pfs;
}
fields.add("dataTime.refTime");// the refTime time field name defined in SoundingSite and decoded modelsounding table
values.add(refTimeStr); //refTime data type defined in SoundingSite is "Date"
operands.add("=");
fields.add("dataTime.validPeriod.start");// the rangeStart field name defined in SoundingSite and decoded modelsounding table
String d="";
for (String timeStr: soundingTimeAry){
d = d+timeStr;
d= d+",";
}
d=d.substring(0, d.length()-1);//get rid of last ","
values.add(d); //rangestart data type defined in SoundingSite is "Date"
operands.add("in");
//for (int i=0; i < fields.size(); i++) {
// System.out.println("field "+ fields.get(i) + " value "+ values.get(i));
//}
List<String> parameters = new ArrayList<String>(12);
parameters.addAll(ModelSoundingPointDataTransform.LVL_PARAMETERS);
parameters.add(ModelSoundingPointDataTransform.P_LATITUDE);
parameters.add(ModelSoundingPointDataTransform.P_LONGITUDE);
parameters.add(ModelSoundingPointDataTransform.P_ELEVATION);
parameters.add(ModelSoundingPointDataTransform.P_STATION_ID);
parameters.add(ModelSoundingPointDataTransform.P_STATION_NUMBER);
parameters.add(ModelSoundingPointDataTransform.P_REF_TIME);
parameters.add(ModelSoundingPointDataTransform.P_FORECAST_HOUR);
try {
long t01 = System.currentTimeMillis();
lSndSiteRecords = ModelSoundingPointDataTransform.getSoundingSites(fields, values, operands, parameters);
long t02 = System.currentTimeMillis();
System.out.println("getPfcSndDataBySoundTimeRangeArray sounding site record size = "+ lSndSiteRecords.size()+
" took "+(t02-t01)+ " ms");
for(SoundingSite sndSite:lSndSiteRecords){
//set pf data
List<NcSoundingLayer> soundLyList = new ArrayList<NcSoundingLayer>();
NcSoundingProfile pf = new NcSoundingProfile();
pf.setStationLatitude(sndSite.getLatitude());
pf.setStationLongitude(sndSite.getLongitude());
pf.setStationElevation((float)sndSite.getElevation());
pf.setFcsTime((sndSite.getDataTime().getFcstTime()*1000)+ sndSite.getDataTime().getRefTime().getTime());
if(sndSite.getSiteId()!=null && sndSite.getSiteId().length()>0)
pf.setStationNum(Integer.parseInt(sndSite.getSiteId()));
pf.setStationId(sndSite.getStationId());
//for (int i=0; i<sizes[0]; i++)
for (SoundingLevel level : sndSite.getLevels())
{
NcSoundingLayer soundingLy = new NcSoundingLayer();
soundingLy.setOmega(level.getOmega().floatValue());
soundingLy.setTemperature((float)kelvinToCelsius.convert(level.getTemperature()));
soundingLy.setPressure(level.getPressure().floatValue()/100);
soundingLy.setWindU(level.getUcWind().floatValue()); // HDF5 data in unit of Knots, no conversion needed
soundingLy.setWindV(level.getVcWind().floatValue());
soundingLy.setSpecHumidity(level.getSpecificHumidity().floatValue());
soundLyList.add(soundingLy);
}
Collections.sort(soundLyList,reversePressureComparator());
pf.setSoundingLyLst(soundLyList);
pfs.add(pf);
//System.out.println("sounding fcs time = "+ pf.getFcsTime());
//System.out.println("sounding ref time = "+ sndSite.getDataTime().getRefTime().getTime());
}
} catch (Exception e) {
//System.out.println("exception=" + e );
e.printStackTrace();
return pfs;
}
}
//debug
//long t02 = System.currentTimeMillis();
//System.out.println("getPfcSndData2 PFC profile retreival took " + (t02 - t01));
return pfs;
}
*/
}

View file

@ -24,7 +24,13 @@ import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
import java.awt.Point;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.plugin.PluginDao;
@ -32,11 +38,14 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
import com.raytheon.edex.uengine.tasks.ScriptTask;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.persist.IHDFFilePathProvider;
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.localization.IPathManager;
/**
* PointIn task derived from original uEngine PointIn task. Reads a file in from
@ -47,10 +56,13 @@ import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
* Date PR# Engineer Description
* ----------- ---------- ------------ --------------------------
* Mar 29, 2007 njensen Initial Creation
* 03/28/2012 Chin Chen Add new APIs to support query multiple Points at one shoot and using
* dataStore.retrieveGroups()
* </PRE>
*
*/
public class PointIn extends ScriptTask {
public class PointIn {//extends ScriptTask {
private PluginDataObject dataRecord;
@ -79,29 +91,41 @@ public class PointIn extends ScriptTask {
+ " dao");
}
}
public PointIn(String aPlugin, PluginDataObject aDataRecord) {
dataRecord = aDataRecord;
indX = 0;
indY = 0;
try {
dao = PluginFactory.getInstance().getPluginDao(aPlugin);
// dataRecord.getPluginName());
} catch (PluginException e) {
System.out.println("Unable to get " + dataRecord.getPluginName()
+ " dao");
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
*/
*
@Override
public Object execute() throws PluginException {
IDataRecord record = getHDF5DataPoint(dataRecord, indX, indY );
IDataRecord record = getHDF5DataPointNew(dataRecord, indX, indY );
FloatDataRecord fdr = (FloatDataRecord)record;
return fdr.getFloatData()[0];
}
}*/
public float getPointData() throws PluginException {
return ((FloatDataRecord)getHDF5DataPoint(dataRecord, indX, indY )).getFloatData()[0];
}
public Object[] retrieveGroup() throws PluginException {
return dao.getHDF5Data(dataRecord, -1);
}
//public Object[] retrieveGroup() throws PluginException {
// return dao.getHDF5Data(dataRecord, -1);
//}
public IDataRecord getHDF5DataPoint(PluginDataObject object,
/*public IDataRecord getHDF5DataPoint(PluginDataObject object,
int xInd, int yInd) throws PluginException {
Request pointRequest = Request.buildPointRequest(new Point(xInd, yInd) );
@ -109,7 +133,7 @@ public class PointIn extends ScriptTask {
record = new IDataRecord[1];
if (object instanceof IPersistable) {
/* connect to the data store and retrieve the data */
// connect to the data store and retrieve the data
//chin remove this line NcgribDao dao = new NcgribDao();
IDataStore dataStore = dao.getDataStore((IPersistable) object);
try {
@ -121,6 +145,110 @@ public class PointIn extends ScriptTask {
}
}
return record[0];
}*/
public IDataRecord getHDF5DataPoint(PluginDataObject object,
int xInd, int yInd) throws PluginException {
Request pointRequest = Request.buildPointRequest(new Point(xInd, yInd) );
IDataRecord[] dr = null;
//record = new IDataRecord[1];
if (object instanceof IPersistable) {
//chin remove this line NcgribDao dao = new NcgribDao();
IDataStore dataStore = dao.getDataStore((IPersistable) object);
try {
String[] groups = new String[1];
groups[0] = object.getDataURI();
dr= dataStore.retrieveGroups(groups, pointRequest);
for (int k = 0; k < dr.length; k++) {
float[] data = (float[]) dr[k].getDataObject();
}
} catch (Exception e) {
throw new PluginException("Error getting HDF5 data", e);
}
}
return dr[0];
}
/*
//from efficientRetirevePoint()
public float[] getHDF5GroupDataPoint(Object[] objects) throws PluginException {
float[] rval = new float[objects.length];
Request pointRequest = Request.buildPointRequest(new Point(indX, indY) );
IDataRecord[] dr = null;
//record = new IDataRecord[1];
if (objects[0] instanceof IPersistable) {
IDataStore dataStore = dao.getDataStore((IPersistable) objects[0]);
try {
String[] groups = new String[objects.length];
for(int i=0; i<objects.length; i++){
groups[i] = ((PluginDataObject)objects[i]).getDataURI();
}
dr= dataStore.retrieveGroups(groups, pointRequest);
for (int k = 0, index=0; k < dr.length; k++, index++) {
float[] data = (float[]) dr[k].getDataObject();
rval[index] = data[0];
}
} catch (Exception e) {
throw new PluginException("Error getting HDF5 data", e);
}
}
return rval;
}
*/
/**
*
* This API is to query grid data for multiple Points and multiple parameters.
* Parameters can be same parameter but at different pressure level. They will be treated
* as different parameters.
* @param objects :parameters to be query
* @param points : query locations, they are index in a 2 dimensional grid (can not use
* lat/lon directly). Use PointUtil.determineIndex to convert from lat/lon
* to Point.
*
*/
public List<float[]> getHDF5GroupDataPoints(Object[] objects, List<Point> points) throws PluginException {
List<float[]> rval = new ArrayList<float[]>();
Request pointRequest = (Request.buildPointRequest(points.toArray(new Point[points.size()])));
IDataRecord[] dr = null;
//record = new IDataRecord[1];
if (objects[0] instanceof IPersistable) {
/* connect to the data store and retrieve the data */
IDataStore dataStore = dao.getDataStore((IPersistable) objects[0]);
try {
String[] groups = new String[objects.length];
for(int i=0; i<objects.length; i++){
groups[i] = ((PluginDataObject)objects[i]).getDataURI();
}
dr= dataStore.retrieveGroups(groups, pointRequest);
int totalRec=0;
if( dr.length >0){
for(Point pt: points){
float[] ptData = new float[dr.length];
rval.add(ptData);
}
}
for (int k = 0, index=0; k < dr.length; k++, index++) {
float[] data = (float[]) dr[k].getDataObject();
//note; data.length should be the same as points.size()
//if(k==0)
// System.out.println("data[] szie="+data.length+ " parameter group size="+dr.length);
totalRec = totalRec + data.length;
for(int i=0; i< data.length; i++){
float[] pData = rval.get(i);
pData[k]= data[i];
}
}
System.out.println("total points = "+ points.size()+ " totalRec = "+totalRec);
} catch (Exception e) {
throw new PluginException("Error getting HDF5 data", e);
}
}
return rval;
}
}

View file

@ -6,6 +6,10 @@ class NcSoundingDataRequest():
def __init__(self):
self.NcSoundingDrv = NcSoundingDrv()
def setNcSoundingLayer2(self, useLayer2):
self.NcSoundingDrv.setUseNcSoundingLayer2(useLayer2)
def setLat(self, lat):
self.NcSoundingDrv.setLat(lat)
self.lat = lat
@ -14,6 +18,20 @@ class NcSoundingDataRequest():
self.NcSoundingDrv.setLon(lon)
self.lon = lon
def setRangeTimeArr(self,rtArr):
from jep import jarray, JLONG_ID
jTA = jarray(len(rtArr), JLONG_ID)
for i in range(len(rtArr)):
jTA[i] = long(rtArr[i])
self.NcSoundingDrv.setRangeTimeArr(jTA)
def setLatLonArr(self, LatLonArr):
from jep import jarray, JDOUBLE_ID
jA = jarray(len(LatLonArr), JDOUBLE_ID)
for i in range(len(LatLonArr)):
jA[i] = LatLonArr[i]
self.NcSoundingDrv.setLatLons(jA)
def setRefTime(self, refTime):
self.NcSoundingDrv.setRefTime(refTime)
self.refTime = refTime
@ -64,11 +82,11 @@ class NcSoundingDataRequest():
self.NcSoundingDrv.setDbIdList(jA)
def setLatLonList(self, LatLonArr):
from jep import jarray, JFLOAT_ID
jA = jarray(len(LatLonArr)*len(LatLonArr[0]), JFLOAT_ID, 0)
from jep import jarray, JDOUBLE_ID
jA = jarray(len(LatLonArr)*len(LatLonArr[0]), JDOUBLE_ID, 0)
for i in range(len(LatLonArr)):
for j in range(len(LatLonArr[0])):
jA[i*len(LatLonArr)+j] = float(LatLonArr[i][j])
jA[i*len(LatLonArr)+j] = LatLonArr[i][j]
self.NcSoundingDrv.setLatLons(jA)
def setTimeLine(self, timeLine):
@ -121,52 +139,33 @@ class NcSoundingDataRequest():
def getSoundingDataByLatLonArray(self, LatLonArr):
self.NcSoundingDrv.setQueryType("LATLON")
from jep import jarray, JFLOAT_ID
jA = jarray(len(LatLonArr), JFLOAT_ID)
from jep import jarray, JDOUBLE_ID
jA = jarray(len(LatLonArr), JDOUBLE_ID)
for i in range(len(LatLonArr)):
jA[i] = float(LatLonArr[i])
jA[i] = LatLonArr[i]
self.NcSoundingDrv.setLatLons(jA)
self.result = self.NcSoundingDrv.getSoundingDataByLatLonArray()
self.result = self.NcSoundingDrv.getSoundingDataGeneric()
#was self.result = self.NcSoundingDrv.getSoundingDataByLatLonArray()
if self.result is None:
return self.makeNullResponse()
else:
return self.makeResponse()
def getSoundingLayer2DataByLatLonArray(self, LatLonArr):
# print'from NcSoundingDataRequest.getSoundingLayer2DataByLatLonArray'
def getSoundingDataByRangeTimeArray(self, rtArr):
self.NcSoundingDrv.setQueryType("LATLON")
from jep import jarray, JFLOAT_ID
jA = jarray(len(LatLonArr), JFLOAT_ID)
for i in range(len(LatLonArr)):
jA[i] = float(LatLonArr[i])
self.NcSoundingDrv.setLatLons(jA)
# print'just before calling self.NcSoundingDrv.getSoundingLayer2DataUsingLatLonArray()'
self.result = self.NcSoundingDrv.getSoundingLayer2DataUsingLatLonArray()
from jep import jarray, JLONG_ID
jTA = jarray(len(rtArr), JLONG_ID)
for i in range(len(rtArr)):
jTA[i] = long(rtArr[i])
self.NcSoundingDrv.setRangeTimeArr(jTA)
self.result = self.NcSoundingDrv.getSoundingDataGeneric()
# self.result = self.NcSoundingDrv.getSoundingDataByRangeTimeArray()
if self.result is None:
# print 'unable to get the sounding cube back'
return self.makeNullResponse()
else:
# print 'Got the sounding cube back'
return self.makeResponse()
def getSoundingLayer2DataByLatLonArray1(self, LatLonArr):
# This method calling per station base algorithm. It is not used for production.
self.NcSoundingDrv.setQueryType("LATLON")
from jep import jarray, JFLOAT_ID
jA = jarray(len(LatLonArr), JFLOAT_ID)
for i in range(len(LatLonArr)):
jA[i] = float(LatLonArr[i])
self.NcSoundingDrv.setLatLons(jA)
# print'just before calling self.NcSoundingDrv.getSoundingLayer2DataUsingLatLonArray()'
self.result = self.NcSoundingDrv.getSoundingLayer2DataUsingLatLonArrayPerStn()
if self.result is None:
# print 'unable to get the sounding cube back'
return self.makeNullResponse()
else:
# print 'Got the sounding cube back'
return self.makeResponse()
return self.makeResponse()
def getSoundingDataByStnIdArray(self, StnIdArr):
self.NcSoundingDrv.setQueryType("STNID")
from jep import jarray
@ -175,8 +174,8 @@ class NcSoundingDataRequest():
for i in range(len(StnIdArr)):
jA[i] = String(StnIdArr[i])
self.NcSoundingDrv.setStnIdArr(jA)
self.result = self.NcSoundingDrv.getSoundingDataByStnArray()
self.result = self.NcSoundingDrv.getSoundingDataGeneric()
# self.result = self.NcSoundingDrv.getSoundingDataByStnArray()
if self.result is None:
return self.makeNullResponse()
else:
@ -190,13 +189,52 @@ class NcSoundingDataRequest():
for i in range(len(StnNumArr)):
jA[i] = String(StnNumArr[i])
self.NcSoundingDrv.setStnNumArr(jA)
self.result = self.NcSoundingDrv.getSoundingDataByStnArray()
self.result = self.NcSoundingDrv.getSoundingDataGeneric()
# self.result = self.NcSoundingDrv.getSoundingDataByStnArray()
if self.result is None:
return self.makeNullResponse()
else:
return self.makeResponse()
def getSoundingData2ByStnIdArray(self, stnIdArr):
self.NcSoundingDrv.setQueryType("STNID")
from jep import jarray
from java.lang import String
jA = jarray(len(stnIdArr), String)
for i in range(len(stnIdArr)):
jA[i] = String(stnIdArr[i])
self.NcSoundingDrv.setStnIdArr(jA)
self.result = self.NcSoundingDrv.getSoundingData2Generic()
if self.result is None:
return self.makeNullResponse()
else:
return self.makeResponse()
def getSoundingData2ByLatLonArray(self, LatLonArr):
# print'from NcSoundingDataRequest.getSoundingLayer2DataByLatLonArray'
self.NcSoundingDrv.setQueryType("LATLON")
from jep import jarray, JDOUBLE_ID
jA = jarray(len(LatLonArr), JDOUBLE_ID)
for i in range(len(LatLonArr)):
jA[i] = LatLonArr[i]
self.NcSoundingDrv.setLatLons(jA)
# print'just before calling self.NcSoundingDrv.getSoundingLayer2DataUsingLatLonArray()'
self.result = self.NcSoundingDrv.getSoundingData2Generic()
if self.result is None:
# print 'unable to get the sounding cube back'
return self.makeNullResponse()
else:
# print 'Got the sounding cube back'
return self.makeResponse()
def getModelSoundingModelNames (self):
self.result = self.NcSoundingDrv.getModels()
if self.result is None:
return self.makeNullResponse()
else:
return self.makeResponse()
# Chin: query DB from Python script directly. Much slower than from Java. Obsoleted and replaced by getModelSoundingModelNames()
def getSoundingModelNames (self, plugin):
from java.util import ArrayList
from com.raytheon.edex.uengine.tasks.query import TableQuery

View file

@ -249,7 +249,7 @@ public class NctextuiPaletteWindow extends ViewPart implements SelectionListener
* Invoked by the workbench to initialize this View.
*/
public void init( IViewSite site ) {
//System.out.println("nctextuiPaletteWindow inited!!");
try {
super.init( site );
@ -259,7 +259,7 @@ public class NctextuiPaletteWindow extends ViewPart implements SelectionListener
pie.printStackTrace();
}
NctextuiResource.registerMouseHandler();
page = site.getPage();
page.addPartListener(this);
@ -269,46 +269,36 @@ public class NctextuiPaletteWindow extends ViewPart implements SelectionListener
* Disposes resource. invoked by the workbench
*/
public void dispose() {
if ( ! isEditorVisible ) return;
super.dispose();
// System.out.println("NctextuiPaletteWindow dispose me, isEditorVisible="+ isEditorVisible);
if ( ! isEditorVisible ){
NctextuiResource.unregisterMouseHandler();
return;
}
else {
super.dispose();
//System.out.println("NctextuiPaletteWindow dispose me");
NCMapEditor editor = NctextuiResource.getMapEditor();
if ( editor !=null ) {
for ( IRenderableDisplay display : UiUtil.getDisplaysFromContainer(editor) ) {
//System.out.println("display " + display.toString());
for ( ResourcePair rp : display.getDescriptor().getResourceList() ) {
if ( rp.getResource() instanceof NctextuiResource ) {
NctextuiResource rsc = (NctextuiResource)rp.getResource();
rsc.unload();
// display.getDescriptor().getResourceList().removePreRemoveListener(rsc);
}
}
//System.out.println("rp "+ rp.getResource().getName());
NCMapEditor editor = NctextuiResource.getMapEditor();
if ( editor !=null ) {
for ( IRenderableDisplay display : UiUtil.getDisplaysFromContainer(editor) ) {
//System.out.println("display " + display.toString());
for ( ResourcePair rp : display.getDescriptor().getResourceList() ) {
if ( rp.getResource() instanceof NctextuiResource ) {
NctextuiResource rsc = (NctextuiResource)rp.getResource();
rsc.unload();
}
}
}
}
nctextuiPaletteWindow = null;
}
}
nctextuiPaletteWindow = null;
/*
* remove the workbench part listener
*/
page.removePartListener(this);
/*
* remove the workbench part listener
*/
page.removePartListener(this);
}
//if( NmapUiUtils.getActiveNatlCntrsEditor() != null ){
//getNctextuiResource().setPoints(null);
//NmapUiUtils.getActiveNatlCntrsEditor().refresh();
//reset mouse handler to default
//NmapUiUtils.setPanningMode();
//}
//close editor
// if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null && NctextuiResource.getMapEditor() != null ){
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(NctextuiResource.getMapEditor(), false);
// }
}
private void close () {

View file

@ -97,7 +97,7 @@ public class NctextuiMouseHandler extends InputHandlerDefaultImpl {
*/
@Override
public boolean handleMouseUp(int x, int y, int button) {
//System.out.println("mouse up");
//System.out.println("NctextuiMouseHandler mouse up");
// button 1 is left mouse button
if (button == 1 ){

View file

@ -11,6 +11,9 @@
* ------------ ---------- ----------- --------------------------
* 06/28/2011 T402 X. Guo Re-format NCTEXT view panel, check
* the click action on nctext legend
* 02/15/2012 T627 Archana Updated the call to addRbd() to accept
* a NCMapEditor object as one of the arguments
* Removed the call to setNcEditor()
*/
package gov.noaa.nws.ncep.ui.nctextui.rsc;
@ -104,8 +107,7 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
// create an editor MapEditor
if(mapEditor != null)
return;
File rbdFile = NcPathManager.getInstance().getStaticFile(
NcPathConstants.DFLT_RBD );
try {
IEditorPart ep = EditorUtil.getActiveEditor();
if ( ep instanceof NCMapEditor ) {
@ -113,17 +115,17 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
}
else {
mapEditor = NmapUiUtils.createNatlCntrsEditor("BasicWX-US","NCTEXT" );
File rbdFile = NcPathManager.getInstance().getStaticFile(
NcPathConstants.DFLT_RBD );
RbdBundle rbd = RbdBundle.unmarshalRBD( rbdFile, null );
ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap");
rbdLoader.addRBD( rbd, mapEditor );
VizApp.runSync( rbdLoader );
}
RbdBundle rbd = RbdBundle.unmarshalRBD( rbdFile, null );
rbd.setNcEditor( (NCMapEditor)mapEditor );
ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap");
rbdLoader.addRBD( rbd );
VizApp.runSync( rbdLoader );
// mapEditorNum = mapEditor.getEditorNum();
//register mouse handler
mouseHandler = getMouseHandler();
mapEditor.registerMouseHandler((IInputHandler) mouseHandler );
mouseHandler = getMouseHandler();
mapEditor.registerMouseHandler((IInputHandler) mouseHandler );
//System.out.println("NctextuiPaletteWindow create editor "+ mapEditor.toString());
}
catch ( Exception ve ) {
@ -205,9 +207,21 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
closeTextView ();
nctextuiResource = null;
}
public static void registerMouseHandler(){
mouseHandler = getMouseHandler();
if(mapEditor!=null && mouseHandler!=null)
mapEditor.registerMouseHandler((IInputHandler) mouseHandler );
}
public static void unregisterMouseHandler(){
mouseHandler = getMouseHandler();
if(mapEditor!=null && mouseHandler!=null)
mapEditor.unregisterMouseHandler((IInputHandler) mouseHandler );
}
@Override
public void propertiesChanged(ResourceProperties updatedProps) {
//System.out.println("NctextuiResource:propertiesChanged");
if ( updatedProps.isVisible() ) {
reopenTextView ();
}
@ -218,7 +232,7 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
private void hideTextView () {
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
//System.out.println("NctextuiResource:hideTextView");
IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.NCTEXTUI" );
if ( wpage.isPartVisible(vpart) ) {
NctextuiPaletteWindow paletteWin = NctextuiPaletteWindow.getAccess();
@ -227,6 +241,7 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
}
}
private void closeTextView () {
//System.out.println("NctextuiResource:closeTextView");
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(wpage!= null){
IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.NCTEXTUI" );
@ -237,6 +252,7 @@ public class NctextuiResource extends AbstractVizResource<NctextuiResourceData,
}
private void reopenTextView () {
//System.out.println("NctextuiResource:reopenTextView");
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.NCTEXTUI" );

View file

@ -3,14 +3,37 @@
* First code: 05/2010.
*
*/
#ifndef _WIN32
#include "gui.h"
#endif
#include "sharp95.h"
#include "Sndglib/profile.h"
#include "Sndglib/setsndg.h"
#include "Sndglib/sndglib.h"
/*
* In Cave: parameters are defined dynamically in "populateSndgDataStatic()" in this file. Its index are defined
* as followings.
*/
#define NPARM 7 /* Assume always using 7 parameters "PRES;HGHT;TEMP;DWPT;DRCT;SPED;OMEG".*/
#define NLEVEL 150 /* assume max sounding layers 150 */
#define PPRESS 0
#define PHGHT 1
#define PTEMP 2
#define PDEW 3
#define PWDIR 4
#define PWSPED 5
#define POMEG 6
//Chin's NOTE: AWC Nsharp source code parameters definitions are different from BigNsharp
/* They defined as,
* sndg[numlvl][0] = omega
* sndg[numlvl][1] = pressure
* sndg[numlvl][2] = height
* sndg[numlvl][3] = temperature
* sndg[numlvl][4] = dew point
* sndg[numlvl][5] = wind direction
* sndg[numlvl][6] = wind speed
* Therefore, when porting AWC Nsharp code, make sure convert to right parameters in CAVE.
*/
//this is copy from sndg_parms..but adding typedef for our implementation
typedef struct Sndg_parms
{
@ -32,6 +55,24 @@ typedef struct stormSlinkyStr
int color[200];
} StormSlinkyStr;
/* cloud amount definition for FM algorithm */
#define OVC 1
#define BKN 2
#define SCT 3
#define FEW 4
#define MAX_CLOUD_LAYER 20
typedef struct cloudInfoStr
{
/* FM: Fred Mosher's Algorithm */
int sizeFM;
float preStartFM[MAX_CLOUD_LAYER];
float preEndFM[MAX_CLOUD_LAYER];
int cloudTypeFM[MAX_CLOUD_LAYER];
/* CE: Chernykh and Eskridge Algorithm */
int sizeCE;
float preStartCE[MAX_CLOUD_LAYER];
float preEndCE[MAX_CLOUD_LAYER];
}CloudInfoStr;
struct Sounding staticSounding;
@ -61,13 +102,13 @@ void initStaticGlobalsMem(){
}
new->parms = (char **) &parmsPtr;
strcpy(&parms[0][0], "PRES");
strcpy(&parms[1][0], "HGHT");
strcpy(&parms[2][0], "TEMP");
strcpy(&parms[3][0], "DWPT");
strcpy(&parms[4][0], "DRCT");
strcpy(&parms[5][0], "SPED");
strcpy(&parms[6][0], "OMEG");
strcpy(&parms[PPRESS][0], "PRES");
strcpy(&parms[PHGHT][0], "HGHT");
strcpy(&parms[PTEMP][0], "TEMP");
strcpy(&parms[PDEW][0], "DWPT");
strcpy(&parms[PWDIR][0], "DRCT");
strcpy(&parms[PWSPED][0], "SPED");
strcpy(&parms[POMEG][0], "OMEG");
new->nparms = NPARM;
for(j=0;j<NLEVEL;j++) {
new->parms[j] = (char **)&parms[j][0];
@ -122,20 +163,20 @@ int populateSndgDataStatic(CaveSndgParms snDataArray[], int arraySize, int data
/* Populate data*/
for (i=0;i<minArraySize;i++)
{
s->data[i][0] = snDataArray[i].pres;
s->origdata[i][0] = snDataArray[i].pres;
s->data[i][1] = snDataArray[i].hght;
s->origdata[i][1] = snDataArray[i].hght;
s->data[i][2] = snDataArray[i].temp;
s->origdata[i][2] = snDataArray[i].temp;
s->data[i][3] = snDataArray[i].dwpt;
s->origdata[i][3] = snDataArray[i].dwpt;
s->data[i][4] = snDataArray[i].drct;
s->origdata[i][4] = snDataArray[i].drct;
s->data[i][5] = snDataArray[i].sped;
s->origdata[i][5] = snDataArray[i].sped;
s->data[i][6] = snDataArray[i].omega;
s->origdata[i][6] = snDataArray[i].omega;
s->data[i][PPRESS] = snDataArray[i].pres;
s->origdata[i][PPRESS] = snDataArray[i].pres;
s->data[i][PHGHT] = snDataArray[i].hght;
s->origdata[i][PHGHT] = snDataArray[i].hght;
s->data[i][PTEMP] = snDataArray[i].temp;
s->origdata[i][PTEMP] = snDataArray[i].temp;
s->data[i][PDEW] = snDataArray[i].dwpt;
s->origdata[i][PDEW] = snDataArray[i].dwpt;
s->data[i][PWDIR] = snDataArray[i].drct;
s->origdata[i][PWDIR] = snDataArray[i].drct;
s->data[i][PWSPED] = snDataArray[i].sped;
s->origdata[i][PWSPED] = snDataArray[i].sped;
s->data[i][POMEG] = snDataArray[i].omega;
s->origdata[i][POMEG] = snDataArray[i].omega;
}
@ -181,13 +222,13 @@ int populateSndgData(CaveSndgParms snDataArray[], int arraySize, int datatype)
strcpy(parms, "PRES;HGHT;TEMP;DWPT;DRCT;SPED;OMEG");
for (i=0;i<arraySize;i++)
{
snd[i][0]= snDataArray[i].pres;
snd[i][1]= snDataArray[i].hght;
snd[i][2]= snDataArray[i].temp;
snd[i][3]= snDataArray[i].dwpt;
snd[i][4]= snDataArray[i].drct;
snd[i][5]= snDataArray[i].sped;
snd[i][6]= snDataArray[i].omega; //copy it anyway
snd[i][PPRESS]= snDataArray[i].pres;
snd[i][PHGHT]= snDataArray[i].hght;
snd[i][PTEMP]= snDataArray[i].temp;
snd[i][PDEW]= snDataArray[i].dwpt;
snd[i][PWDIR]= snDataArray[i].drct;
snd[i][PWSPED]= snDataArray[i].sped;
snd[i][POMEG]= snDataArray[i].omega; //copy it anyway
}
@ -1063,3 +1104,188 @@ float cave_criticalAngel(){
printf("\nCRITICAL ANGLE = %0.1f\n", ca);*/
return ca;
}
float F1(float x) {
if (x >= -10)
return 1.0;
else
return (-.1*(x+70)+7);
}
float F2(float x) {
if (x>=0)
return 2.0;
else if (x>=-10 && x<0)
return (-.025*(x+10)+2.5);
else
return(-.125*(x+70)+10.0);
}
float F3(float x) {
if (x>=0)
return 3.0;
else if (x>=-10 && x<0)
return(-0.1*(x+10)+4.0);
else
return(-0.15*(x+50)+10.0);
}
int getCloudAmount(float temp,float dd) {
if (dd<F1(temp))
return 1;
else if (dd<F2(temp))
return 2;
else if (dd<F3(temp))
return 3;
else
return 4;
}
void draw_Clouds( struct cloudInfoStr *cloudStr )
/*****************************************************************/
/* DRAW_CLOUDS */
/* LARRY J. HINSON AWC/KCMO */
/* Chin: ported from "AWC nsharp" and modified for CAVE */
/* Note: sndg parameter index is changed to be in line with BigNsharp
* implementation.
*/
/*****************************************************************/
{
int startflag,s1,s2,s3,i,spsub,epsub;
float T1,T2,T3,dz,d2T,R1,R2,R3,d2R,startpres,endpres,x1,x2,y,t2,p2;
float Tavg,DDavg,DD;
float dd1,dd2,dd3,d2x;
int cloudAmt,top,basefound;
float d2xparam=0.0000;
float Taccum=0.0;
float DDaccum=0.0;
float TCount=0.0;
startflag=0;
cloudStr->sizeFM=0;
cloudStr->sizeCE=0;
for (i=1;i<numlvl-2/*chin was -1*/;i++) {
s1=i-1;
s2=i;
s3=i+1;
if (sndg[s1][PTEMP]>-900.0 && sndg[s2][PTEMP] > -900.0 && sndg[s3][PTEMP]>-900) {
T1=sndg[s1][PTEMP];
T2=sndg[s2][PTEMP];
T3=sndg[s3][PTEMP];
dz=sndg[s3][PHGHT]-sndg[s1][PHGHT];
if (dz==0) dz=1;
d2T=(T3-2*T2+T1)/(dz*dz);
R1=100*mixratio(sndg[s1][PPRESS],sndg[s1][PDEW])/mixratio(sndg[s1][PPRESS],sndg[s1][PTEMP]);
R2=100*mixratio(sndg[s2][PPRESS],sndg[s2][PDEW])/mixratio(sndg[s2][PPRESS],sndg[s2][PTEMP]);
R3=100*mixratio(sndg[s3][PPRESS],sndg[s3][PDEW])/mixratio(sndg[s3][PPRESS],sndg[s3][PTEMP]);
d2R=(R3-2*R2+R1)/(dz*dz);
if (d2T>=0 && d2R<=0 && !startflag) {
startflag=1;
startpres=sndg[s2][PPRESS];
spsub=s2;
}
else if ( !(d2T>=0 && d2R<=0) && startflag) {
startflag=0;
endpres=sndg[s2][PPRESS];
epsub=s2;
Tavg=Taccum/TCount;
DDavg=DDaccum/TCount;
cloudAmt=getCloudAmount(Tavg,DDavg);
Taccum=0.0;
DDaccum=0.0;
TCount=0;
if (cloudAmt != FEW && cloudStr->sizeFM <MAX_CLOUD_LAYER) {
cloudStr->preStartFM[cloudStr->sizeFM]= startpres;
cloudStr->preEndFM[cloudStr->sizeFM]= endpres;
cloudStr->cloudTypeFM[cloudStr->sizeFM] = cloudAmt;
cloudStr->sizeFM++;
}
}
if ((d2T>=0 && d2R<=0) && startflag) {
Taccum+=sndg[s2][PTEMP];
DD=sndg[s2][PTEMP]-sndg[s2][PDEW];
DDaccum+=DD;
TCount++;
}
}
}
top=0;
for (i=numlvl-2/* was -1*/;i>0; i--) {
basefound=0;
s1=i-1;
s2=i;
s3=i+1;
if (sndg[s1][PTEMP]>-900.0 && sndg[s2][PTEMP] > -900.0 && sndg[s3][PTEMP]>-900) {
if (! top) {
dd1=sndg[s1][PTEMP]-sndg[s1][PDEW];
dd2=sndg[s2][PTEMP]-sndg[s2][PDEW];
dd3=sndg[s3][PTEMP]-sndg[s3][PDEW];
dz=(sndg[s3][PHGHT]-sndg[s1][PHGHT])/2.0;
if (dz==0) dz=1;
d2x=(dd3-2*dd2+dd1)/(dz*dz);
if (d2x>0 && dd2<4.5) {
top=-1;
endpres=sndg[s2][PPRESS];
epsub=s2;
/* Now work downward till you get moistening with height */
/* Do this until you reach lowest level of this condition */
;
while(i>1 && ! basefound) {
i--;
s1=i-1;
s2=i;
s3=i+1;
if (sndg[s1][PTEMP]>-900.0 && sndg[s2][PTEMP] > -900.0 && sndg[s3][PTEMP]>-900) {
dd1=sndg[s1][PTEMP]-sndg[s1][PDEW];
dd2=sndg[s2][PTEMP]-sndg[s2][PDEW];
dd3=sndg[s3][PTEMP]-sndg[s3][PDEW];
dz=(sndg[s3][PHGHT]-sndg[s1][PHGHT])/2.0;
if (dz==0) dz=1;
d2x=(dd3-2*dd2+dd1)/(dz*dz);
if (d2x < -d2xparam) {
while ((d2x < -d2xparam && dd2<4.5) && i>1) {
i--;
s1=i-1;
s2=i;
s3=i+1;
if (sndg[s1][PTEMP]>-900.0 && sndg[s2][PTEMP] > -900.0 && sndg[s3][PTEMP]>-900) {
dd1=sndg[s1][PTEMP]-sndg[s1][PDEW];
dd2=sndg[s2][PTEMP]-sndg[s2][PDEW];
dd3=sndg[s3][PTEMP]-sndg[s3][PDEW];
dz=(sndg[s3][PHGHT]-sndg[s1][PHGHT])/2.0;
if (dz==0) dz=1;
d2x=(dd3-2*dd2+dd1)/(dz*dz);
}
}
/* Lowest level of drying found...compute LCL from s1*/
drylift(sndg[s1][PPRESS],sndg[s1][PTEMP],sndg[s1][PDEW],&p2,&t2);
startpres=p2;
if (startpres<endpres) {
startpres=sndg[s1][PPRESS];
}
spsub=s1;
top=0;
basefound=-1;
if (cloudStr->sizeCE <MAX_CLOUD_LAYER) {
cloudStr->preStartCE[cloudStr->sizeCE]= startpres;
cloudStr->preEndCE[cloudStr->sizeCE]= endpres;
cloudStr->sizeCE++;
}
//setcolor(2);
//XFillRectangle(XtDisplay(draw_reg), canvas, gc,50,pres_to_pix(endpres),
// 90-50,pres_to_pix(startpres)-pres_to_pix(endpres));
}
}
}
}
}
}
}
}

View file

@ -14,7 +14,7 @@ void flipflopsounding(float **inoutsndg, int nlev)
int i, j;
if (nlev >= MAXLEV) {
fprintf(stderr, "WTF? flipflopsounding. nlev >= MAXLEV\n");
fprintf(stderr, " flipflopsounding. nlev >= MAXLEV\n");
}
/* First copy stuff into temporary array */

View file

@ -39,6 +39,7 @@
#define DISPLAY_LEFT 0
#define DISPLAY_RIGHT 1
#ifndef _WIN32
extern short drawing_mode;
extern short display_mode_left;
extern short display_mode_right;
@ -54,6 +55,7 @@ extern GC gc;
extern Widget draw_reg;
extern Pixmap canvas;
extern XtAppContext app;
#endif
extern short pagenum;
extern short nobanner;

View file

@ -1,4 +1,7 @@
#define GLOBAL
#ifdef _WIN32
#include <stdio.h>
#endif
#include "sharp95.h"
void write_scheme_file(char st[80])

View file

@ -4,7 +4,7 @@
+ sndglist, haillist, fname)
c Jan 27, 2010, REJ.
integer maob,saob
parameter (maob=15000) ! Max number of raobs allowed.
parameter (saob=15) ! Number of raobs to return to NSHARP.
@ -21,7 +21,7 @@ c Jan 27, 2010, REJ.
character datestn*15,dummy*25,matdatestn(maob)*15
character sndglist(saob)*15, fname*(80), fname1*(80)
integer maob,j,cnt,mrmat(maob),capemat(maob),tempmat(maob),
integer j,cnt,mrmat(maob),capemat(maob),tempmat(maob),
& lrmat(maob),shrmat(maob),km9mat(maob),shr3mat(maob),golf,
& sigm(maob),tier1,tier1cnt,srhmat(maob)

View file

@ -43,6 +43,7 @@ History hist;
struct _configure config;
#ifndef _WIN32
void main(int argc, char *argv[])
{
int i;
@ -125,3 +126,4 @@ void main(int argc, char *argv[])
/* Pass args so that X gets command line args */
make_screen(argc, argv);
}
#endif

View file

@ -14,13 +14,17 @@ hpgl.h:1: parse error before `*'
*/
#include "winter.h"
#ifndef _WIN32
#include "xwvideo.h"
#include "save.h"
#endif
#include "globals_xw.h"
#include "config.h"
#include "textsave.h"
#include "sndglib.h"
#ifndef _WIN32
#include "hpgl.h"
#endif
void write_scheme_file(char st[80]);
void write_hail_file(char st[80]);

View file

@ -73,7 +73,6 @@ echo " "
if ( $check == "libbignsharp.so") then
echo "****** Shared library is created ******\n "
echo " "
cp libbignsharp.so $DEV_BASE/workspace/build.cave/static/common/cave/caveEnvironment/lib
cp libbignsharp.so $DEV_BASE/workspace/gov.noaa.nws.ncep.ui.nsharp.linux32
else
echo "****** Houston, we got problems ******\n "

View file

@ -6,7 +6,7 @@ c program sup_nsharp
c SARS For Supercells
integer saob,maob
parameter (maob=15000) ! Max number of raobs allowed.
parameter (saob=15) ! Number of raobs to return to NSHARP.
@ -26,7 +26,7 @@ c SARS For Supercells
character sndglist(saob)*15, fname*(80), fname1*(80)
character tortype(maob)*8,suplist(saob)*8
integer maob,i,j,cnt,mlmrmat(maob),mlcapemat(maob),
integer i,j,cnt,mlmrmat(maob),mlcapemat(maob),
& mlcinmat(maob),mllclmat(maob),mucapemat(maob),sblclmat(maob),
& shrmat(maob),srhmat(maob),tempmat(maob),lrmat(maob),stpmat(maob),
& h500umat(maob),h500vmat(maob),shrcat(maob),matshrcat(maob),tier1,

View file

@ -37,7 +37,7 @@
/***************************************************************/
#define GLOBAL
#define VIDEO
#include "xwcmn.h"
//#include "xwcmn.h"
#include "sharp95.h"
/*
@ -56,11 +56,13 @@ short auto_mode;
int xwdth, xhght, xdpth;
int raob_mod;
#ifndef _WIN32
Pixel pixels[40]; /* for colors */
GC gc;
Widget draw_reg;
Pixmap canvas;
XtAppContext app;
#endif
short pagenum = 1;
short overlay_previous;
@ -71,6 +73,7 @@ struct _skewt skv = { 40, 25, 500, 500, 100, 70, 60, 1};
struct _hodog hov = { 40, 675, 350, 1025, 0, 0, 120, 10};
struct _stpinset stv = { 720, 520, 1080, 790, 0};
struct _startup autostart;
#ifndef _WIN32
typedef struct { /* for drawing moving crosshairs or zoom boxes */
int start_x, start_y,
last_x, last_y;
@ -82,6 +85,7 @@ typedef struct { /* for drawing moving crosshairs or zoom boxes */
} rubber_band_data;
rubber_band_data rbdata;
#endif
/* mkay added functions */
void mixratline(float val);
@ -90,6 +94,7 @@ void display_levels(short colr);
void display_effective_layer(short colr);
/*NP*/
#ifndef _WIN32
void make_screen(int argc, char *argv[])
/*************************************************************/
/* MAKE_SCREEN */
@ -696,7 +701,7 @@ void draw_hodo(void)
*/ }
}
#endif
/*NP*/
void hodo_to_pix(float dir, float mag, short *x, short *y)
/*************************************************************/
@ -783,6 +788,7 @@ void pix_to_hodo(short x, short y, float *dir, float *mag)
*mag = speed(u, v);
}
#ifndef _WIN32
/*NP*/
void trace_hodo(short width)
/*************************************************************/
@ -1494,7 +1500,6 @@ void trace_temp(short width, short colr)
}
/*
This routine has same problems as trace_hodo
@ -1535,7 +1540,6 @@ void trace_temp2(short width)
}
}
/*NP*/
void trace_vtmp(short width)
/*************************************************************/
@ -1575,7 +1579,6 @@ void trace_vtmp(short width)
}
}
/*NP*/
void trace_dwpt(short width, short colr)
/*************************************************************/
@ -1680,7 +1683,6 @@ void trace_dwpt2(short width)
}
}
/*NP*/
void trace_wetbulb(short width)
/*************************************************************/
@ -1722,7 +1724,7 @@ void trace_wetbulb(short width)
}
}
}
#endif
/*NP*/
short pres_to_pix(float pres)
/*************************************************************/
@ -1809,6 +1811,7 @@ float pix_to_temp(short x, short y)
}
/*NP*/
#ifndef _WIN32
void trace_parcel(float pres, float temp, float dwpt)
/*************************************************************/
/* TRACE_PARCEL */
@ -1977,7 +1980,6 @@ void wind_barb(float wdir, float wspd, short x, short y, short siz)
}
}
/*NP*/
void plot_barbs(void)
/*************************************************************/
@ -2133,7 +2135,6 @@ void plot_barbs2(void)
}
/*NP*/
void vvel_profile(void)
/*************************************************************/
@ -2194,7 +2195,6 @@ void vvel_profile(void)
}
}
/*NP*/
void trace_dcape(void)
/*************************************************************/
@ -2291,7 +2291,6 @@ void copytodisplay(void)
XFlush(XtDisplay(draw_reg));
}
void display_dendritic_zone(short width)
{
short i, x, y, xold, yold;
@ -2373,7 +2372,6 @@ void display_dendritic_zone(short width)
}
}
void display_levels(short colr)
{
short i, x, y, xold, yold;
@ -2470,7 +2468,6 @@ void display_levels(short colr)
outgtext(st, skv.tlx+ 35, y-5);
}
void display_effective_layer(short colr)
{
short i, x, y, xold, yold;
@ -2557,3 +2554,4 @@ void display_effective_layer(short colr)
sprintf( st, "%4.0f J/kg", pcl.bplus);
outgtext(st, skv.brx - x2, y1+5); */
}
#endif

View file

@ -38,9 +38,12 @@
/* WW_TYPE */
/***************************************************************/
#ifndef _WIN32
#include "xwcmn.h"
#endif
#include "sharp95.h"
#ifndef _WIN32
short switch_modes(short mode)
/*************************************************************/
/* SWITCH_MODES */
@ -115,6 +118,7 @@ void disp_param(char *value, short rcol, short rlin)
outgtext(value, (rcol - getgtextextent(value)), rlin);
}
#endif
/*
grab_level should return an error as needed
@ -155,7 +159,7 @@ short grab_level(float pres)
}
#ifndef _WIN32
/*NP*/
void skewt_cursor_data( short x, short y )
/*************************************************************/
@ -306,7 +310,7 @@ void hodo_cursor_data( short x, short y )
sprintf( st, "%3.0f", ix4 );
outtext( st, skv.brx+315, skv.tly+60 );
}
#endif
/*

View file

@ -5,6 +5,8 @@ Bundle-SymbolicName: gov.noaa.nws.ncep.ui.nsharp;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: gov.noaa.nws.ncep.ui.nsharp.Activator
Bundle-Vendor: SIB
Eclipse-RegisterBuddy: gov.noaa.nws.ncep.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.uf.common.serialization
Eclipse-BuddyPolicy: ext, global
Require-Bundle: org.eclipse.ui;bundle-version="3.4.1",
org.eclipse.core.runtime;bundle-version="3.4.0",
org.eclipse.core.resources,

View file

@ -0,0 +1,2 @@
gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore
gov.noaa.nws.ncep.ui.nsharp.NsharpLineProperty

View file

@ -58,5 +58,15 @@
name="gov.noaa.nws.ncep.ui.nsharp.skewt.NsharpSkewTDescriptor">
</descriptor>
</extension>
<extension
point="com.raytheon.uf.viz.localization.localizationpath">
<path
application="NCEP"
localizationType="CAVE_STATIC"
name="Nsharp"
recursive="true"
value="ncep/nsharp"
extensionFilter=".xml">
</path>
</extension>
</plugin>

View file

@ -0,0 +1,78 @@
package gov.noaa.nws.ncep.ui.nsharp;
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpConfigHashMapAdaptor
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/21/2012 229 Chin Chen Initial coding
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
import java.util.HashMap;
import java.util.Map.Entry;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class NsharpConfigHashMapAdaptor extends
XmlAdapter<NsharpLinePropertySerializable, HashMap<String, NsharpLineProperty>> {
/*
* (non-Javadoc)
*
* @see
* javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
*/
@Override
public NsharpLinePropertySerializable marshal(
HashMap<String, NsharpLineProperty> v) throws Exception {
if (v == null) {
return null;
}
NsharpLinePropertySerializable serializable = new NsharpLinePropertySerializable();
NsharpLinePropertySerializable.LinePropertyItem[] items = new NsharpLinePropertySerializable.LinePropertyItem[v
.size()];
int i = 0;
for (Entry<String, NsharpLineProperty> entry : v.entrySet()) {
items[i] = new NsharpLinePropertySerializable.LinePropertyItem();
items[i].lineName = entry.getKey();
items[i].lineProperty = entry.getValue();
i++;
}
serializable.items = items;
return serializable;
}
/*
* (non-Javadoc)
*
* @see
* javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
*/
@Override
public HashMap<String, NsharpLineProperty> unmarshal(
NsharpLinePropertySerializable v) throws Exception {
HashMap<String, NsharpLineProperty> map = null;
if (v.items == null) {
map = new HashMap<String, NsharpLineProperty>(0);
} else {
map = new HashMap<String, NsharpLineProperty>(v.items.length);
for (NsharpLinePropertySerializable.LinePropertyItem item : v.items) {
map.put(item.lineName, item.lineProperty);
}
}
return map;
}
}

View file

@ -0,0 +1,130 @@
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpConfigManager
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.
*
* This class handle Nsharp configuration saving and retrieving from file system. It also manages
* current configuration information.
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/13/2012 Chin Chen Initial coding
*
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
package gov.noaa.nws.ncep.ui.nsharp;
import gov.noaa.nws.ncep.ui.nsharp.palette.NsharpGraphConfigDialog;
import gov.noaa.nws.ncep.ui.nsharp.palette.NsharpLineConfigDialog;
import gov.noaa.nws.ncep.viz.localization.NcPathManager;
import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants;
import java.io.File;
import java.util.Map;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.viz.core.exception.VizException;
public class NsharpConfigManager {
private NsharpConfigStore nsharpConfigStore=null;
private static NsharpConfigManager instance=null;
private NsharpConfigManager() {
instance = this;
}
public static NsharpConfigManager getInstance() {
if(instance==null){
new NsharpConfigManager();
}
return instance;
}
public NsharpConfigStore getNsharpConfigStore() {
return nsharpConfigStore;
}
public void setNsharpConfigStore(NsharpConfigStore nsharpConfigStore) {
this.nsharpConfigStore = nsharpConfigStore;
}
//retrieve from file system
public NsharpConfigStore retrieveNsharpConfigStoreFromFs() {
if(nsharpConfigStore == null){
// get configuration from nsharpConfig.xml
Map<String,LocalizationFile> nsharpFiles = NcPathManager.getInstance().listFiles(
NcPathConstants.NSHARP_CONFIG,
new String[]{ ".xml" }, true, true );
for( LocalizationFile lFile : nsharpFiles.values() ) {
try {
System.out.println("lFile name="+ lFile.getName());
Object xmlObj = SerializationUtil.jaxbUnmarshalFromXmlFile(
lFile.getFile().getAbsolutePath() );
if( xmlObj instanceof NsharpConfigStore ) {
nsharpConfigStore = (NsharpConfigStore)xmlObj;
break;
}
} catch (SerializationException e) {
System.out.println("Error unmarshalling file: " + lFile.getFile().getAbsolutePath() );
System.out.println( e.getMessage() );
}
}
}
if(nsharpConfigStore== null){
// could not find configuration nsharpConfig.xml file
nsharpConfigStore = new NsharpConfigStore();
nsharpConfigStore = NsharpGraphConfigDialog.setDefaultGraphConfig(nsharpConfigStore);
nsharpConfigStore=NsharpLineConfigDialog.setDefaultLineConfig(nsharpConfigStore);
}
return nsharpConfigStore;
}
//save to file system
public boolean saveConfigStoreToFs(NsharpConfigStore nsharpConfigStore) throws VizException{
this.nsharpConfigStore = nsharpConfigStore;
// create a localization file for the plotModel
//
LocalizationContext userCntxt = NcPathManager.getInstance().getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER );
LocalizationFile
lFile = NcPathManager.getInstance().getLocalizationFile( userCntxt,
NcPathConstants.NSHARP_CONFIG );
File configFile = lFile.getFile();
try {
SerializationUtil.jaxbMarshalToXmlFile( nsharpConfigStore,
configFile.getAbsolutePath() );
lFile.save();
} catch (LocalizationOpFailedException e) {
throw new VizException( e );
} catch (SerializationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
}

View file

@ -0,0 +1,77 @@
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/13/2012 Chin Chen Initial coding
*
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
package gov.noaa.nws.ncep.ui.nsharp;
import java.util.HashMap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.raytheon.uf.common.serialization.ISerializableObject;
@XmlRootElement(name = "NsharpConfigStore")
@XmlAccessorType(XmlAccessType.NONE)
public class NsharpConfigStore implements ISerializableObject{
//@XmlElement(name = "NsharpLineProperty", required = true)
//private NsharpLineProperty lp;
//public NsharpLineProperty getLp() {
// return lp;
//}
//public void setLp(NsharpLineProperty lp) {
// this.lp = lp;
//}
@XmlElement
private NsharpGraphProperty graphProperty = new NsharpGraphProperty();
@XmlElement
//@XmlJavaTypeAdapter(NsharpConfigHashMapAdaptor.class)
@XmlJavaTypeAdapter(value = NsharpConfigHashMapAdaptor.class)
private HashMap<String, NsharpLineProperty> linePropertyMap = new HashMap<String, NsharpLineProperty>();
public HashMap<String, NsharpLineProperty> getLinePropertyMap() {
return linePropertyMap;
}
public void setLinePropertyMap(
HashMap<String, NsharpLineProperty> linePropertyMap) {
this.linePropertyMap = linePropertyMap;
}
public NsharpGraphProperty getGraphProperty() {
return graphProperty;
}
public void setGraphProperty(NsharpGraphProperty graphProperty) {
this.graphProperty = graphProperty;
}
}

View file

@ -67,6 +67,31 @@ public class NsharpConstants {
public static final double[] PRESSURE_NUMBERING_LEVELS = { 1000, 850,
700, 500, 300, 200, 100 };
//Icing pressure level 1000, 900,800,700,600, 500,400, 300
public static final double ICING_PRESSURE_LEVEL_BOTTOM = 1000;
public static final double ICING_PRESSURE_LEVEL_TOP = 300;
public static final double ICING_PRESSURE_LEVEL_INC = 100;
//Icing relative humidity 100, 90,80,70,60, 50,40, 30,20,10,0
public static final double ICING_RELATIVE_HUMIDITY_LEFT = 0;
public static final double ICING_RELATIVE_HUMIDITY_RIGHT = 100;
public static final double ICING_RELATIVE_HUMIDITY_INC = 10;
//Icing temperature (C) 25,20,15,10,5,0,-5,-10, -15,-20,-25
public static final double ICING_TEMPERATURE_RIGHT = 25;
public static final double ICING_TEMPERATURE_LEFT = -25;
public static final double ICING_TEMPERATURE_INC = 5;
//Turbulence pressure level 1000, 900,800,700,600, 500,400, 300, 200, 100
public static final double TURBULENCE_PRESSURE_LEVEL_TOP =100;
public static final double TURBULENCE_PRESSURE_LEVEL_BOTTOM =1000;
public static final double TURBULENCE_PRESSURE_LEVEL_INC =100;
//Turbulence LN Richardson Number -2,-1, 0, 1,2,3,4,5,6,7,8
public static final double TURBULENCE_LN_RICHARDSON_NUMBER_LEFT =8;
public static final double TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT =-2;
public static final double TURBULENCE_LN_RICHARDSON_NUMBER_INC =-1;
//Turbulence wind shear TKE 50,45,40,35,30,25,20,15,10,5,0
public static final double TURBULENCE_WIND_SHEAR_TKE_LEFT = 0;
public static final double TURBULENCE_WIND_SHEAR_TKE_RIGHT = 50;
public static final double TURBULENCE_WIND_SHEAR_TKE_INC = 5;
// lightGray.
public static final RGB backgroundColor = new RGB(191, 191, 191);
@ -139,9 +164,9 @@ public class NsharpConstants {
public static final int LABEL_PADDING = 5;
public static double bottom = WxMath.getSkewTXY(1050, 0).y;
public static double bottom = NsharpWxMath.getSkewTXY(1050, 0).y;
public static double top = WxMath.getSkewTXY(100, 0).y;
public static double top = NsharpWxMath.getSkewTXY(100, 0).y;
public static double height = top - bottom;
@ -168,6 +193,7 @@ public class NsharpConstants {
public static RGB color_babypink = new RGB(249,207, 221);//
public static RGB color_deeppink = new RGB(255,20, 147);//
public static RGB color_hotpink = new RGB(255,105, 180);//
public static RGB color_pink = new RGB(255, 192, 203);
public static RGB color_stellblue = new RGB(70,130,180);
public static RGB color_royalblue = new RGB(65,105,225);
public static RGB color_skyblue = new RGB(135,206,235);
@ -184,12 +210,27 @@ public class NsharpConstants {
public static final int[] HEIGHT_LEVEL_METERS = {/*16000,*/ 15000, 12000, 9000, 6000, 3000, 2000 };
public static final int[] HEIGHT_LEVEL_FEET = {50000, 45000, 40000, 35000, 30000, 25000, 20000, 15000, 10000, 5000, 2500 };
public static final int SKEWT_REC_X_ORIG = 300;//400;
public static final int SKEWT_REC_Y_ORIG = 150;
public static final int OMEGA_X_TOP = -40;
public static final int OMEGA_Y_TOP = 200;//225;
public static final int SKEWT_REC_X_ORIG = OMEGA_X_TOP + 160;
public static final int SKEWT_REC_Y_ORIG = OMEGA_Y_TOP-75;
public static final int SKEWT_REC_WIDTH = 1000;
public static final int SKEWT_REC_HEIGHT = 1002;
public static final int SKEWT_VIEW_X_END = SKEWT_REC_X_ORIG + SKEWT_REC_WIDTH;
public static final int SKEWT_VIEW_Y_END = SKEWT_REC_Y_ORIG + SKEWT_REC_HEIGHT;
public static final int OMEGA_Y_BOT = SKEWT_VIEW_Y_END-15;
public static final int ICING_REC_X_ORIG =SKEWT_REC_X_ORIG;
public static final int ICING_REC_Y_ORIG = SKEWT_REC_Y_ORIG;
public static final int ICING_REC_WIDTH = SKEWT_REC_WIDTH;
public static final int ICING_REC_HEIGHT = SKEWT_REC_HEIGHT-50;
public static final int ICING_VIEW_X_END = ICING_REC_X_ORIG + ICING_REC_WIDTH;
public static final int ICING_VIEW_Y_END = ICING_REC_Y_ORIG + ICING_REC_HEIGHT;
public static final int TURB_REC_X_ORIG =SKEWT_REC_X_ORIG;
public static final int TURB_REC_Y_ORIG = SKEWT_REC_Y_ORIG ;
public static final int TURB_REC_WIDTH = SKEWT_REC_WIDTH;
public static final int TURB_REC_HEIGHT = SKEWT_REC_HEIGHT -50;
public static final int TURB_VIEW_X_END = TURB_REC_X_ORIG + TURB_REC_WIDTH;
public static final int TURB_VIEW_Y_END = TURB_REC_Y_ORIG + TURB_REC_HEIGHT;
public static final int DATAPANEL_REC_WIDTH = 750;
public static final int DATAPANEL_REC_HEIGHT = 630;
public static final int INSET_REC_WIDTH = DATAPANEL_REC_WIDTH/2;//250;//300;
@ -219,53 +260,10 @@ public class NsharpConstants {
public static final int WIND_MOTION_REC_HEIGHT = 150;
public static final int WIND_MOTION_VIEW_X_END = WIND_MOTION_REC_X_ORIG+WIND_MOTION_REC_WIDTH;
public static final int WIND_MOTION_VIEW_Y_END = WIND_MOTION_REC_Y_ORIG+WIND_MOTION_REC_HEIGHT;
/*
public static final int THETAH_REC_X_ORIG = HODO_REC_X_ORIG;
public static final int THETAH_REC_Y_ORIG = HODO_VIEW_Y_END;
public static final int THETAH_REC_WIDTH = INSET_REC_WIDTH;
public static final int THETAH_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int THETAH_VIEW_X_END = THETAH_REC_X_ORIG+THETAH_REC_WIDTH;
public static final int THETAH_VIEW_Y_END = THETAH_REC_Y_ORIG+THETAH_REC_HEIGHT;
public static final int THETAP_REC_X_ORIG = THETAH_VIEW_X_END;
public static final int THETAP_REC_Y_ORIG = THETAH_REC_Y_ORIG;
public static final int THETAP_REC_WIDTH = INSET_REC_WIDTH;
public static final int THETAP_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int THETAP_VIEW_X_END = THETAP_REC_X_ORIG+THETAP_REC_WIDTH;
public static final int THETAP_VIEW_Y_END = THETAP_REC_Y_ORIG+THETAP_REC_HEIGHT;
public static final int SRWINDS_REC_X_ORIG = THETAP_VIEW_X_END;
public static final int SRWINDS_REC_Y_ORIG = THETAP_REC_Y_ORIG;
public static final int SRWINDS_REC_WIDTH = INSET_REC_WIDTH;
public static final int SRWINDS_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int SRWINDS_VIEW_X_END = SRWINDS_REC_X_ORIG+SRWINDS_REC_WIDTH;
public static final int SRWINDS_VIEW_Y_END = SRWINDS_REC_Y_ORIG+SRWINDS_REC_HEIGHT;
public static final int SRWINDVTRS_REC_X_ORIG = HODO_VIEW_X_END;
public static final int SRWINDVTRS_REC_Y_ORIG = HODO_REC_Y_ORIG;
public static final int SRWINDVTRS_REC_WIDTH = INSET_REC_WIDTH;
public static final int SRWINDVTRS_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int SRWINDVTRS_VIEW_X_END = SRWINDVTRS_REC_X_ORIG+SRWINDVTRS_REC_WIDTH;
public static final int SRWINDVTRS_VIEW_Y_END = SRWINDVTRS_REC_Y_ORIG+SRWINDVTRS_REC_HEIGHT;
public static final int STORMSLINKY_REC_X_ORIG = SRWINDVTRS_REC_X_ORIG;
public static final int STORMSLINKY_REC_Y_ORIG = SRWINDVTRS_VIEW_Y_END;
public static final int STORMSLINKY_REC_WIDTH = INSET_REC_WIDTH;
public static final int STORMSLINKY_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int STORMSLINKY_VIEW_X_END = STORMSLINKY_REC_X_ORIG+STORMSLINKY_REC_WIDTH;
public static final int STORMSLINKY_VIEW_Y_END = STORMSLINKY_REC_Y_ORIG+STORMSLINKY_REC_HEIGHT;
public static final int PSBLWATCH_REC_X_ORIG = STORMSLINKY_REC_X_ORIG;
public static final int PSBLWATCH_REC_Y_ORIG = STORMSLINKY_VIEW_Y_END;
public static final int PSBLWATCH_REC_WIDTH = INSET_REC_WIDTH;
public static final int PSBLWATCH_REC_HEIGHT = INSET_REC_HEIGHT;
public static final int PSBLWATCH_VIEW_X_END = PSBLWATCH_REC_X_ORIG+PSBLWATCH_REC_WIDTH;
public static final int PSBLWATCH_VIEW_Y_END = PSBLWATCH_REC_Y_ORIG+PSBLWATCH_REC_HEIGHT;*/
public static final int DATA_TIMELINE_REC_X_ORIG = HODO_VIEW_X_END;
public static final int DATA_TIMELINE_REC_Y_ORIG = HODO_REC_Y_ORIG;
public static final int DATA_TIMELINE_REC_WIDTH = 280;//330;//280;
public static final int DATA_TIMELINE_REC_WIDTH =330;//280;
public static final int DATA_TIMELINE_REC_HEIGHT = SKEWT_REC_HEIGHT-90;
public static final int DATA_TIMELINE_VIEW_X_END = DATA_TIMELINE_REC_X_ORIG+DATA_TIMELINE_REC_WIDTH;
public static final int DATA_TIMELINE_VIEW_Y_END = DATA_TIMELINE_REC_Y_ORIG+DATA_TIMELINE_REC_HEIGHT;
@ -274,7 +272,7 @@ public class NsharpConstants {
public static final int DATA_TIMELINE_SORT_X_START = DATA_TIMELINE_REC_X_ORIG+(7*DATA_TIMELINE_REC_WIDTH/18);
public static final int STATION_ID_REC_X_ORIG = DATA_TIMELINE_VIEW_X_END;
public static final int STATION_ID_REC_Y_ORIG = DATA_TIMELINE_REC_Y_ORIG;
public static final int STATION_ID_REC_WIDTH = 100;//160;
public static final int STATION_ID_REC_WIDTH = 300;
public static final int STATION_ID_REC_HEIGHT = DATA_TIMELINE_REC_HEIGHT;
public static final int STATION_ID_VIEW_X_END = STATION_ID_REC_X_ORIG+STATION_ID_REC_WIDTH;
public static final int STATION_ID_VIEW_Y_END = STATION_ID_REC_Y_ORIG+STATION_ID_REC_HEIGHT;
@ -286,11 +284,8 @@ public class NsharpConstants {
public static final int COLOR_NOTATION_VIEW_X_END = COLOR_NOTATION_REC_X_ORIG+COLOR_NOTATION_REC_WIDTH;
public static final int COLOR_NOTATION_VIEW_Y_END = COLOR_NOTATION_REC_Y_ORIG+COLOR_NOTATION_REC_HEIGHT;
public static final int OMEGA_X_TOP = SKEWT_REC_X_ORIG-160;
public static final int OMEGA_Y_TOP = SKEWT_REC_Y_ORIG+ 75;
public static final int OMEGA_Y_BOT = SKEWT_VIEW_Y_END-15;
public static final int DATAPANEL1_REC_X_ORIG = OMEGA_X_TOP-80;
public static final int DATAPANEL1_REC_X_ORIG = OMEGA_X_TOP+150;
public static final int DATAPANEL1_REC_Y_ORIG = SKEWT_VIEW_Y_END + 50;
public static final int DATAPANEL1_REC_WIDTH = DATAPANEL_REC_WIDTH;
public static final int DATAPANEL1_REC_HEIGHT = DATAPANEL_REC_HEIGHT;
@ -371,11 +366,16 @@ public class NsharpConstants {
public static int btnGapX = 5;
public static int btnGapY = 5;
public static int listWidth = 160;
public static int listHeight = 100;
public static int listHeight = 80;
public static int filelistWidth = 120;
public static int filelistHeight = 100;
public static int dsiplayPanelSize = 2;
public static int GRAPH_SKEWT = 0;
public static int GRAPH_ICING = 1;
public static int GRAPH_TURB = 2;
public static int MAX_GRAPH_MODE = 3;
public static String getNlistFile() {
return NcPathManager.getInstance().getStaticFile(
NcPathConstants.NSHARP_NLIST_FILE ).getAbsolutePath();
@ -384,4 +384,31 @@ public class NsharpConstants {
return NcPathManager.getInstance().getStaticFile(
NcPathConstants.NSHARP_SUP_FILE ).getAbsolutePath();
}
//Line configuration. Line name listing order in this array should be in order with constant defined below it.
public static String[] lineNameArray= {"Temperature", "Dew Point", "Parcel","Virtual Temp","Wetbulb","Wind Barb","Overlay 1", "Overlay 2", "Compare 1", "Compare 2","Compare 3","Compare 4","Compare 5","Compare 6","Compare 7","Compare 8","Compare 9","Compare 10",
"Icing RH", "Icing Temp", "Icing EPI", "Turbulence Ln", "Turbulence WindShear"};
public static int LINE_TEMP = 0;
public static int LINE_DEWP = 1;
public static int LINE_PARCEL = 2;
public static int LINE_VIRTUAL_TEMP =3;
public static int LINE_WETBULB = 4;
public static int LINE_WIND_BARB = 5;
public static int LINE_OVERLAY1 = 6;
public static int LINE_OVERLAY2= 7;
public static int LINE_COMP1 = 8;
public static int LINE_COMP2 = 9;
public static int LINE_COMP3 = 10;
public static int LINE_COMP4 = 11;
public static int LINE_COMP5 = 12;
public static int LINE_COMP6 = 13;
public static int LINE_COMP7 = 14;
public static int LINE_COMP8 = 15;
public static int LINE_COMP9 = 16;
public static int LINE_COMP10 = 17;
public static int LINE_ICING_RH = 18;
public static int LINE_ICING_TEMP= 19;
public static int LINE_ICING_EPI=20;
public static int LINE_TURBULENCE_LN = 21;
public static int LINE_TURBULENCE_WS = 22;
}

View file

@ -0,0 +1,262 @@
package gov.noaa.nws.ncep.ui.nsharp;
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/21/2012 229 Chin Chen Initial coding
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
@XmlRootElement(name = "NsharpGraphProperty")
@XmlAccessorType(XmlAccessType.NONE)
public class NsharpGraphProperty implements ISerializableObject{
@XmlAttribute
private boolean temp;
@XmlAttribute
private boolean dewp;
@XmlAttribute
private boolean parcel;
@XmlAttribute
private boolean VTemp;
@XmlAttribute
private boolean wetBulb;
@XmlAttribute
private boolean mixratio;
@XmlAttribute
private boolean dryAdiabat;
@XmlAttribute
private boolean moistAdiabat;
@XmlAttribute
private boolean effLayer;
@XmlAttribute
private boolean cloud;
@XmlAttribute
private boolean hodo;
@XmlAttribute
private boolean meanWind;
@XmlAttribute
private boolean smv3075;
@XmlAttribute
private boolean smv1585;
@XmlAttribute
private boolean smvBunkersR;
@XmlAttribute
private boolean smvBunkersL;
@XmlAttribute
private boolean omega;
@XmlAttribute
private boolean corfidiV;
@XmlAttribute
private boolean windBarb;
@XmlAttribute
private int windBarbDistance;
@XmlAttribute
private int tempOffset;
public boolean isTemp() {
return temp;
}
public void setTemp(boolean temp) {
this.temp = temp;
}
public boolean isDewp() {
return dewp;
}
public void setDewp(boolean dewp) {
this.dewp = dewp;
}
public boolean isParcel() {
return parcel;
}
public void setParcel(boolean parcel) {
this.parcel = parcel;
}
public boolean isVTemp() {
return VTemp;
}
public void setVTemp(boolean vTemp) {
VTemp = vTemp;
}
public boolean isWetBulb() {
return wetBulb;
}
public void setWetBulb(boolean wetBulb) {
this.wetBulb = wetBulb;
}
public boolean isMixratio() {
return mixratio;
}
public void setMixratio(boolean mixratio) {
this.mixratio = mixratio;
}
public boolean isDryAdiabat() {
return dryAdiabat;
}
public void setDryAdiabat(boolean dryAdiabat) {
this.dryAdiabat = dryAdiabat;
}
public boolean isMoistAdiabat() {
return moistAdiabat;
}
public void setMoistAdiabat(boolean moistAdiabat) {
this.moistAdiabat = moistAdiabat;
}
public boolean isEffLayer() {
return effLayer;
}
public void setEffLayer(boolean effLayer) {
this.effLayer = effLayer;
}
public boolean isCloud() {
return cloud;
}
public void setCloud(boolean cloud) {
this.cloud = cloud;
}
public boolean isHodo() {
return hodo;
}
public void setHodo(boolean hodo) {
this.hodo = hodo;
}
public boolean isMeanWind() {
return meanWind;
}
public void setMeanWind(boolean meanWind) {
this.meanWind = meanWind;
}
public boolean isSmv3075() {
return smv3075;
}
public void setSmv3075(boolean smv3075) {
this.smv3075 = smv3075;
}
public boolean isSmv1585() {
return smv1585;
}
public void setSmv1585(boolean smv1585) {
this.smv1585 = smv1585;
}
public boolean isSmvBunkersR() {
return smvBunkersR;
}
public void setSmvBunkersR(boolean smvBunkersR) {
this.smvBunkersR = smvBunkersR;
}
public boolean isSmvBunkersL() {
return smvBunkersL;
}
public void setSmvBunkersL(boolean smvBunkersL) {
this.smvBunkersL = smvBunkersL;
}
public boolean isOmega() {
return omega;
}
public void setOmega(boolean omega) {
this.omega = omega;
}
public boolean isCorfidiV() {
return corfidiV;
}
public void setCorfidiV(boolean corfidiV) {
this.corfidiV = corfidiV;
}
public boolean isWindBarb() {
return windBarb;
}
public void setWindBarb(boolean windBarb) {
this.windBarb = windBarb;
}
public int getWindBarbDistance() {
return windBarbDistance;
}
public void setWindBarbDistance(int windBarbDistance) {
this.windBarbDistance = windBarbDistance;
}
public int getTempOffset() {
return tempOffset;
}
public void setTempOffset(int tempOffset) {
this.tempOffset = tempOffset;
}
}

View file

@ -0,0 +1,83 @@
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpLineProperty
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/13/2012 Chin Chen Initial coding
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
package gov.noaa.nws.ncep.ui.nsharp;
import gov.noaa.nws.ncep.viz.common.RGBColorAdapter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
@XmlRootElement(name = "NsharpLineProperty")
@XmlAccessorType(XmlAccessType.NONE)
public class NsharpLineProperty implements ISerializableObject{
//@XmlAttribute
//private String lineName="";
@XmlAttribute
private LineStyle lineStyle;
@XmlAttribute
private int lineWidth;
@XmlElement
@XmlJavaTypeAdapter(RGBColorAdapter.class)
private RGB lineColor;
public NsharpLineProperty() {
super();
lineWidth = 1;
lineColor = NsharpConstants.color_white;
lineStyle = LineStyle.SOLID;
}
//public String getLineName() {
// return lineName;
//}
//public void setLineName(String lineName) {
// this.lineName = lineName;
//}
public LineStyle getLineStyle() {
return lineStyle;
}
public void setLineStyle(LineStyle lineStyle) {
this.lineStyle = lineStyle;
}
public int getLineWidth() {
return lineWidth;
}
public void setLineWidth(int lineWidth) {
this.lineWidth = lineWidth;
}
public RGB getLineColor() {
return lineColor;
}
public void setLineColor(RGB lineColor) {
this.lineColor = lineColor;
}
}

View file

@ -0,0 +1,42 @@
package gov.noaa.nws.ncep.ui.nsharp;
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpLinePropertySerializable
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/13/2012 Chin Chen Initial coding
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.NONE)
public class NsharpLinePropertySerializable {
@XmlElement(name = "Line")
public LinePropertyItem[] items;
@XmlType(name = "lineItem")
public static class LinePropertyItem {
@XmlAttribute(name = "lineName")
public String lineName;
@XmlElement(name = "lineProperty")
public NsharpLineProperty lineProperty;
}
}

View file

@ -21,19 +21,58 @@
package gov.noaa.nws.ncep.ui.nsharp;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
public class NsharpStationInfo {
protected float latitude;
protected float longitude;
//protected float elevation;
protected Timestamp reftime;
public class timeLineSpecific {
Timestamp tiemLine;
String displayInfo;
public Timestamp getTiemLine() {
return tiemLine;
}
public void setTiemLine(Timestamp tiemLine) {
this.tiemLine = tiemLine;
}
public String getDisplayInfo() {
return displayInfo;
}
public void setDisplayInfo(String displayInfo) {
this.displayInfo = displayInfo;
}
}
protected List<timeLineSpecific> timeLineSpList = new ArrayList<timeLineSpecific>();
//Chin PER protected float latitude;
//protected float longitude;
protected double latitude;
protected double longitude;
protected Timestamp reftime; //uair (same as Synoptictime in uair)
protected Timestamp rangestarttime; //rangestart used by model sounding e.g. PFC sounding, or uair (same as Synoptictime in uair)
//protected List<Integer> dbId = new ArrayList<Integer>(); // used by observed data (e.g uair) only
protected String stnDisplayInfo;
//protected String datauri;
protected String sndType;
protected String stnId;
public String getStnId() {
return stnId;
}
public void setStnId(String stnId) {
this.stnId = stnId;
}
public List<timeLineSpecific> getTimeLineSpList() {
return timeLineSpList;
}
public void setTimeLineSpList(List<timeLineSpecific> timeLineSpList) {
this.timeLineSpList = timeLineSpList;
}
public void addToTimeLineSpList(timeLineSpecific timeLineSpInfo,int index ) {
this.timeLineSpList.add(index,timeLineSpInfo);
}
public void addToTimeLineSpList(timeLineSpecific timeLineSpInfo) {
this.timeLineSpList.add(timeLineSpInfo);
}
public String getSndType() {
return sndType;
}
@ -46,12 +85,6 @@ public class NsharpStationInfo {
public void setRangestarttime(Timestamp rangestarttime) {
this.rangestarttime = rangestarttime;
}
//public String getDatauri() {
// return datauri;
//}
//public void setDatauri(String datauri) {
//// this.datauri = datauri;
//}
public Timestamp getReftime() {
return reftime;
}
@ -64,29 +97,17 @@ public class NsharpStationInfo {
public void setStnDisplayInfo(String stnDisplayInfo) {
this.stnDisplayInfo = stnDisplayInfo;
}
//public List<Integer> getDbId() {
// return dbId;
//}
//public void setDbId(List<Integer> dbId) {
// this.dbId = dbId;
//}
public float getLatitude() {
public double getLatitude() {
return latitude;
}
public void setLatitude(float latitude) {
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public float getLongitude() {
public double getLongitude() {
return longitude;
}
public void setLongitude(float longitude) {
public void setLongitude(double longitude) {
this.longitude = longitude;
}
//public float getElevation() {
// return elevation;
//}
//public void setElevation(float elevation) {
// this.elevation = elevation;
//}
}

View file

@ -0,0 +1,70 @@
package gov.noaa.nws.ncep.ui.nsharp;
/**
*
* gov.noaa.nws.ncep.ui.nsharp.NsharpWxMath
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/13/2012 Chin Chen Initial coding, port from WxMath class
* using Nsharp own configured tempOffset
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
import com.vividsolutions.jts.geom.Coordinate;
public class NsharpWxMath {
public static int tempOffset = 0;
public static void setTempOffset(int tempOffset) {
NsharpWxMath.tempOffset = tempOffset;
}
/**
* Convert a pressure and temperature to a skew-t x,y coordinate in
* centimeters where 0,0 occurs at 1000 hPa and 0 degrees Celsius.
*
* @param pressure
* The pressure in hectoPascals (millibars).
* @param temperature
* The temperature in degrees Celsius.
* @return The calculated coordinate in centimeters.
*/
public static final Coordinate getSkewTXY(double pressure,
double temperature) {
temperature -= tempOffset;
Coordinate point = new Coordinate();
point.y = 132.182 - 44.061 * Math.log10(pressure);
point.x = (0.54 * temperature) + (0.90692 * point.y);
return point;
}
/**
* Reverse a skewT coordinate (in centimeters) to the corresponding
* temperature and pressure.
*
* @param point
* @return The temperature and pressure. coordinate.x = temperature in
* Celsius, coordinate.y = the pressure in hectoPascals (millibars).
*/
public static final Coordinate reverseSkewTXY(Coordinate point) {
Coordinate tempPressure = new Coordinate();
tempPressure.y = Math.pow(10, ((point.y - 132.182) / -44.061));
tempPressure.x = (point.x - (0.90692 * point.y)) / 0.54;
tempPressure.x += tempOffset;
return tempPressure;
}
}

View file

@ -1,6 +1,6 @@
/**
*
* gov.noaa.nws.ncep.viz.ui.locator.resource.SurfaceStationPointData
* gov.noaa.nws.ncep.ui.nsharp.SurfaceStationPointData
*
* This java class performs the surface station locator functions.
* This code has been developed by the SIB for use in the AWIPS2 system.

View file

@ -36,10 +36,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
import org.geotools.referencing.GeodeticCalculator;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
@ -51,7 +56,6 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl {
public NsharpMapMouseHandler() {
instance = this;
}
//private NsharpSkewTDisplay renderableDisplay=null;
@ -502,19 +506,21 @@ using hdf5 obj lib
*/
@Override
public boolean handleMouseUp(int x, int y, int button) {
//System.out.println("NsharpMapMouseHandler handleMouseUp called");
// button 1 is left mouse button
if (button == 1 ){
//TBD NCMapEditor mapEditor = NmapUiUtils.getActiveNatlCntrsEditor();
NCMapEditor mapEditor = NsharpMapResource.getMapEditor();
if(mapEditor != null){
//for(int i=0; i< mapEditor.getDescriptor().getResourceList().size(); i++)
// System.out.println( "C resourcename="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName());
// Check if mouse is in geographic extent
Coordinate loc = mapEditor.translateClick(x, y);
if ( loc == null )
return false;
NsharpLoadDialog loadDia = NsharpLoadDialog.getAccess();
if(loadDia!=null){
if(loadDia.getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND && loadDia.getMdlDialog()!=null){
if(loadDia.getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND && loadDia.getMdlDialog()!=null&& loadDia.getMdlDialog().getLocationText()!=null){
if(loadDia.getMdlDialog().getCurrentLocType() == ModelSoundingDialogContents.LocationType.STATION){
//System.out.println("mouse up 1 loc.x "+ loc.x+ " loc.y="+ loc.y);
@ -534,23 +540,28 @@ using hdf5 obj lib
}
else {
//get the stn (point) list
int activeLoadType = loadDia.getActiveLoadSoundingType();
List<NsharpStationInfo> points = NsharpMapResource.getOrCreateNsharpMapResource().getPoints();//loadDia.getNsharpMapResource().getPoints();
if(points.isEmpty() == false){
//get the stn close to loc "enough" and retrieve report for it
// Note::One stn may have more than one dataLine, if user picked multiple data time lines
List<NsharpStationInfo> stnPtDataLineLst = getPtWithinMinDist(points, loc);
if(stnPtDataLineLst!= null && stnPtDataLineLst.size() > 0){
if(stnPtDataLineLst!= null && stnPtDataLineLst.size() > 0){
//System.out.println("MapMouseHandler creating NsharpSkewTDisplay");
//hash map, use stn display info as key
Map<String, List<NcSoundingLayer>> soundingLysLstMap = new HashMap<String, List<NcSoundingLayer>>();
int activeLoadType = loadDia.getActiveLoadSoundingType();
//String soundingType;
if(activeLoadType == NsharpLoadDialog.OBSER_SND){
if(activeLoadType == NsharpLoadDialog.OBSER_SND){
NsharpMapResource.startWaitCursor();
NsharpObservedSoundingQuery.getObservedSndData(stnPtDataLineLst,loadDia.getObsDialog().isRawData(),soundingLysLstMap);
NsharpMapResource.stopWaitCursor();
}
else if (activeLoadType == NsharpLoadDialog.PFC_SND){
NsharpPfcSoundingQuery.getPfcSndData(stnPtDataLineLst,soundingLysLstMap);
//soundingType= loadDia.getPfcDialog().getCurrentSndType().toString();
NsharpMapResource.startWaitCursor();
NsharpPfcSoundingQuery.getPfcSndDataBySndTmRange(stnPtDataLineLst,soundingLysLstMap);
NsharpMapResource.stopWaitCursor();
}
else
return false;
@ -580,6 +591,7 @@ using hdf5 obj lib
if (mapEditor != null) {
mapEditor.refresh();
}
bringSkewTEdToTop();
}
else
{
@ -596,7 +608,30 @@ using hdf5 obj lib
}
return true;
else if(button == 3){
//NsharpSkewTEditor.bringSkewTEditorToTop();
bringSkewTEdToTop();
}
return false;
}
/*
* Chin Note: If calling NsharpSkewTEditor.bringSkewTEditorToTop() directly in mouse handler API, e.g.
* handleMouseUp(), then handleMouseUp() will be called one more time by System. Do not know the root cause of it.
* To avoid handling such event twice (e.g. query sounding data twice), we will call NsharpSkewTEditor.bringSkewTEditorToTop()
* from another Job (thread).
*/
private void bringSkewTEdToTop(){
Job uijob = new UIJob("clear source selection"){ //$NON-NLS-1$
public IStatus runInUIThread(
IProgressMonitor monitor) {
NsharpSkewTEditor.bringSkewTEditorToTop();
return Status.OK_STATUS;
}
};
uijob.setSystem(true);
uijob.schedule();
}
/**
@ -611,7 +646,6 @@ using hdf5 obj lib
double minDistance = NctextuiPointMinDistance;
GeodeticCalculator gc;
List<NsharpStationInfo> thePoints = new ArrayList<NsharpStationInfo>();
//TBD NCMapEditor mapEditor = NmapUiUtils.getActiveNatlCntrsEditor();
NCMapEditor mapEditor = NsharpMapResource.getMapEditor();
if(mapEditor != null){
IMapDescriptor desc = (IMapDescriptor) mapEditor.getActiveDisplayPane().getRenderableDisplay().getDescriptor();

View file

@ -11,7 +11,7 @@
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/23/2010 229 Chin Chen Initial coding
*
*
* </pre>
*
* @author Chin Chen
@ -25,7 +25,13 @@ import java.io.File;
import java.util.List;
import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
@ -40,6 +46,7 @@ import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList.RemoveListener;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.ui.EditorUtil;
@ -51,6 +58,7 @@ import gov.noaa.nws.ncep.viz.resources.manager.ResourceBndlLoader;
import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants;
import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo;
import gov.noaa.nws.ncep.ui.nsharp.palette.NsharpPaletteWindow;
import gov.noaa.nws.ncep.ui.pgen.display.DisplayElementFactory;
import gov.noaa.nws.ncep.ui.pgen.display.IDisplayable;
import gov.noaa.nws.ncep.ui.pgen.elements.SymbolLocationSet;
@ -63,10 +71,13 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
private static NsharpMapResource mapRsc=null;
private static NCMapEditor mapEditor=null;
private static NsharpMapMouseHandler mouseHandler;
private static Cursor waitCursor=null;
private static Control cursorControl;
private static boolean mouseHandlerRegistered=false;
public static void bringMapEditorToTop(){
try{
if(mapEditor!=null){
if(mapEditor!=null&& PlatformUI.getWorkbench()!=null && PlatformUI.getWorkbench().getActiveWorkbenchWindow()!=null
&& PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()!=null){
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(mapEditor);
mapEditor.refresh();
}
@ -105,8 +116,6 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
else{
this.points = points;
}
}
public void addPoint(NsharpStationInfo point) {
@ -121,30 +130,102 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
super(resourceData, loadProperties);
this.nsharpMapResourceData = resourceData;
//System.out.println("NsharpMapResource constructed");
}
public static void startWaitCursor(){
waitCursor = new Cursor( Display.getCurrent(), SWT.CURSOR_WAIT);
cursorControl = Display.getCurrent().getCursorControl();
if(cursorControl!=null && waitCursor!=null)
cursorControl.setCursor(waitCursor);
}
public static void stopWaitCursor(){
if(cursorControl!=null&& waitCursor!=null){
cursorControl.setCursor(null);
}
if(waitCursor!=null){
waitCursor.dispose();
waitCursor= null;
}
}
private static void createMapEditor(){
// create an editor MapEditor
File rbdFile = NcPathManager.getInstance().getStaticFile(
NcPathConstants.DFLT_RBD );
try {
IEditorPart ep = EditorUtil.getActiveEditor();
if (ep instanceof NCMapEditor) {
mapEditor= (NCMapEditor) ep;
}else {
mapEditor = NmapUiUtils.createNatlCntrsEditor("BasicWX-US","NSHARP" );
}
for(int i=0; i< mapEditor.getDescriptor().getResourceList().size(); i++)
System.out.println( "A resourcename="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName());
RbdBundle rbd = RbdBundle.unmarshalRBD( rbdFile, null );
rbd.setNcEditor((NCMapEditor) mapEditor );
ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap");
rbdLoader.addRBD( rbd );
rbdLoader.addRBD( rbd, mapEditor );
VizApp.runSync( rbdLoader );
//System.out.println("NsharpMapResource create editor "+ mapEditor.toString());
for(int i=0; i< mapEditor.getDescriptor().getResourceList().size(); i++)
System.out.println( "B resourcename="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName());
}
catch ( Exception ve ) {
System.out.println("NsharpMapResource Could not load initial editor: " + ve.getMessage());
ve.printStackTrace();
}
}
private static void createMapEditorTest(){
// create an editor MapEditor
File rbdFile = NcPathManager.getInstance().getStaticFile(
NcPathConstants.DFLT_RBD );
try {
IEditorPart ep = EditorUtil.getActiveEditor();
if (ep instanceof NCMapEditor) {
mapEditor= (NCMapEditor) ep;
System.out.println("NsharpMapResource using existing editor ");
}else {
mapEditor = NmapUiUtils.createNatlCntrsEditor("BasicWX-US","NSHARP" );
RbdBundle rbd = RbdBundle.unmarshalRBD( rbdFile, null );
ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap");
rbdLoader.addRBD( rbd, mapEditor );
VizApp.runSync( rbdLoader );
System.out.println("NsharpMapResource create new editor "+ mapEditor.toString());
}
for(int i=0; i< mapEditor.getDescriptor().getResourceList().size(); i++)
System.out.println( "Editor resource "+ i+" name="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName());
}
catch ( Exception ve ) {
System.out.println("NsharpMapResource Could not load initial editor: " + ve.getMessage());
ve.printStackTrace();
}
}
public static void registerMouseHandler(){
if(mouseHandlerRegistered)
return;
mouseHandler = getMouseHandler();
if(mapEditor!=null && mouseHandler!=null){
mapEditor.registerMouseHandler((IInputHandler) mouseHandler );
mouseHandlerRegistered = true;
}
}
public static void unregisterMouseHandler(){
if(!mouseHandlerRegistered)
return;
mouseHandler = getMouseHandler();
if(mapEditor!=null && mouseHandler!=null){
mapEditor.unregisterMouseHandler((IInputHandler) mouseHandler );
mouseHandlerRegistered= false;
}
}
/**
* Create a new MapResource and add it to the current editor.
* @return the MapResource
@ -152,7 +233,7 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
public static NsharpMapResource getOrCreateNsharpMapResource() {
if(mapRsc == null ){
if(mapEditor == null)
createMapEditor();
createMapEditorTest();//createMapEditor();
if(mapEditor!=null){
IMapDescriptor desc = (IMapDescriptor) mapEditor.getActiveDisplayPane().getRenderableDisplay().getDescriptor();
try {
@ -205,6 +286,10 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
symbolSet = null;
symbolToMark = null;
mapRsc = null;
if(waitCursor!=null)
waitCursor.dispose();
waitCursor=null;
mouseHandlerRegistered= false;
}
@ -405,6 +490,7 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
return mouseHandler;
}
@Override
public boolean okToUnload() {
/*
@ -420,6 +506,44 @@ public class NsharpMapResource extends AbstractVizResource<NsharpMapResourceDat
// TODO Auto-generated method stub
}
@Override
public void propertiesChanged(ResourceProperties updatedProps) {
if ( updatedProps.isVisible() ) {
reopenTextView ();
}
else {
hideTextView ();
}
}
private void hideTextView () {
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.nsharp" );
if ( wpage.isPartVisible(vpart) ) {
NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance();
if(paletteWin!=null){
paletteWin.setEditorVisible(false);
wpage.hideView(vpart);
}
}
}
private void reopenTextView () {
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.nsharp" );
if ( !wpage.isPartVisible(vpart) ) {
NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance();
if(paletteWin!=null){
paletteWin.setEditorVisible(true);
try {
vpart = wpage.showView( "gov.noaa.nws.ncep.ui.nsharp" );
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

View file

@ -29,7 +29,7 @@ public class NsharpMapResourceData extends AbstractResourceData {
private MarkerState markerState = MarkerState.MARKER_ONLY;
private MarkerType markerType = MarkerType.DIAMOND;
private Float markerSize = 2f;
private Float markerSize = 1f;
private Integer markerWidth = 2;
private MarkerTextSize markerTextSize = MarkerTextSize.MEDIUM;
private String mapName = "NSHARP";

View file

@ -105,58 +105,85 @@ public class NsharpObservedSoundingQuery {
*/
//Chin-T public static void getObservedSndData(List<NsharpStationInfo> stnPtDataLineLst, Map<String, List<SoundingLayer>> soundingLysLstMap) {
//Chin: note that Nsharp currently GUI only allow user pick one stn at one time, but could be many refTimes.
public static void getObservedSndData(List<NsharpStationInfo> stnPtDataLineLst, boolean rawData, Map<String, List<NcSoundingLayer>> soundingLysLstMap) {
//String pickedStnInfo = "";
List<Coordinate> coords= new ArrayList<Coordinate>();
List<Long> refTimeLst = new ArrayList<Long>();
//create refTime array and lat/lon array
for(NsharpStationInfo StnPt : stnPtDataLineLst){
//one StnPt represent one data time line
//List<Integer> Ids = StnPt.getDbId();
//System.out.println("stn lat ="+StnPt.getLatitude()+ " lon="+StnPt.getLongitude());
List<Coordinate> coords= new ArrayList<Coordinate>();
Coordinate coord = new Coordinate(StnPt.getLongitude(),StnPt.getLatitude());
coords.add(coord);
//testing
/*Coordinate coord = new Coordinate(91.93000030517578, 21.43000030517578);
coords.add(coord);
coord = new Coordinate(91.80999755859375, 22.350000381469727);
coords.add(coord);
coord = new Coordinate(90.36000061035156, 22.75);
coords.add(coord);
coord = new Coordinate(89.16000366210938, 23.18000030517578);
coords.add(coord);
coord = new Coordinate(90.37999725341797, 23.760000228881836);
coords.add(coord);
coord = new Coordinate(89.05000305175781, 24.1299991607666);
coords.add(coord);
coord = new Coordinate(91.87999725341797, 24.899999618530273);
coords.add(coord);
coord = new Coordinate(89.36000061035156, 24.850000381469727);
coords.add(coord);*/
NcSoundingCube cube = NcSoundingQuery.soundingQueryByLatLon(StnPt.getReftime().getTime(), coords, StnPt.getSndType(),
NcSoundingLayer.DataType.ALLDATA, !rawData, "-1");
if(cube != null && cube.getRtnStatus()==NcSoundingCube.QueryStatus.OK){
NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0);
//System.out.println("size of profile = "+ cube.getSoundingProfileList().size());
//debug
//for(NcSoundingProfile pf: cube.getSoundingProfileList()){
// System.out.println("sounding profile: lat="+pf.getStationLatitude()+" lon="+pf.getStationLongitude()+ " stnId="+ pf.getStationId() );
//}
List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
// Chin-T List<SoundingLayer> sndLyList = NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst);
if(rtnSndLst != null && rtnSndLst.size() > 0){
//update sounding data so they can be used by Skewt Resource and PalletWindow
if(rawData)
rtnSndLst = NsharpDataHandling.sortObsSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
else
rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
//minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough
// We need at least 2 regular layers for plotting
if(rtnSndLst != null && rtnSndLst.size() > 4)
soundingLysLstMap.put(StnPt.getStnDisplayInfo(), rtnSndLst);
System.out.println("stn lat ="+StnPt.getLatitude()+ " lon="+StnPt.getLongitude());
boolean exist = false;
for(Coordinate c: coords){
if(c.x == StnPt.getLongitude() && c.y == StnPt.getLatitude()){
exist= true;
break;
}
}
if(exist==false) {
Coordinate coord = new Coordinate(StnPt.getLongitude(),StnPt.getLatitude());
coords.add(coord);
}
exist = false;
for(long t: refTimeLst){
if(t == StnPt.getReftime().getTime()){
exist= true;
break;
}
}
if(exist==false) {
refTimeLst.add(StnPt.getReftime().getTime());
}
} // end for loop of stnPtsLst
}
double[][] latLon = new double[coords.size()][2];
for (int i=0; i< coords.size(); i++){
latLon[i][0]= coords.get(i).y; //lat
latLon[i][1]= coords.get(i).x; //lon
}
NcSoundingCube cube = NcSoundingQuery.uaGenericSoundingQuery(refTimeLst.toArray(new Long[0]), latLon, stnPtDataLineLst.get(0).getSndType(),
NcSoundingLayer.DataType.ALLDATA, !rawData, "-1");
//NcSoundingCube cube = NcSoundingQuery.soundingQueryByLatLon(stnPtDataLineLst.get(0).getReftime().getTime(), coords, stnPtDataLineLst.get(0).getSndType(),
// NcSoundingLayer.DataType.ALLDATA, !rawData, "-1");
if(cube != null && cube.getSoundingProfileList().size()>0 && cube.getRtnStatus()==NcSoundingCube.QueryStatus.OK){
for(NcSoundingProfile sndPf : cube.getSoundingProfileList()){
List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
//if(rtnSndLst != null && rtnSndLst.size() > 0){
//NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0);
//System.out.println("size of profile = "+ cube.getSoundingProfileList().size());
//debug
//for(NcSoundingProfile pf: cube.getSoundingProfileList()){
// System.out.println("sounding profile: lat="+pf.getStationLatitude()+" lon="+pf.getStationLongitude()+ " stnId="+ pf.getStationId() );
//}
//List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
// Chin-T List<SoundingLayer> sndLyList = NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst);
if(rtnSndLst != null && rtnSndLst.size() > 0){
//update sounding data so they can be used by Skewt Resource and PalletWindow
if(rawData)
rtnSndLst = NsharpDataHandling.sortObsSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
else
rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
//minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough
// We need at least 2 regular layers for plotting
if(rtnSndLst != null && rtnSndLst.size() > 4){
String dispInfo="";
for(NsharpStationInfo StnPt : stnPtDataLineLst){
if(StnPt.getReftime().getTime() == sndPf.getFcsTime()){
dispInfo = StnPt.getStnDisplayInfo();
break;
}
}
soundingLysLstMap.put(dispInfo, rtnSndLst);
}
}
}
//}
}
}
}

View file

@ -13,7 +13,7 @@ package gov.noaa.nws.ncep.ui.nsharp.maprsc;
* ------- ------- -------- -----------
* 11/1/2010 362 Chin Chen Initial coding
* 12/16/2010 362 Chin Chen add support of BUFRUA observed sounding and PFC (NAM and GFS) model sounding data
*
* 02/15/2012 Chin Chen add PFC sounding query algorithm for better performance getPfcSndDataBySndTmRange()
* </pre>
*
* @author Chin Chen
@ -28,6 +28,9 @@ import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
// Chin-T import com.raytheon.uf.common.sounding.SoundingLayer;
public class NsharpPfcSoundingQuery {
@ -52,38 +55,91 @@ public class NsharpPfcSoundingQuery {
} */
//Chin-T public static void getPfcSndData(List<NsharpStationInfo> stnPtDataLineLst, Map<String, List<SoundingLayer>> soundingLysLstMap) {
public static void getPfcSndData(List<NsharpStationInfo> stnPtDataLineLst, Map<String, List<NcSoundingLayer>> soundingLysLstMap) {
String pickedStnInfo = "";
/*public static void getPfcSndData(List<NsharpStationInfo> stnPtDataLineLst, Map<String, List<NcSoundingLayer>> soundingLysLstMap) {
for(NsharpStationInfo StnPt : stnPtDataLineLst){
//one StnPt represent one data time line
//NcSoundingProfile sndPf= PfcSoundingQuery.getPfcSndData(StnPt.getDatauri(),(float)StnPt.getLatitude(), (float)StnPt.getLongitude(), StnPt.getReftime(),
// StnPt.getRangestarttime(), PfcSoundingQuery.PfcSndType.NAMSND);
//query using NcSoundingQuery class
float[][] latLon = {{StnPt.getLatitude(), StnPt.getLongitude()}};
NcSoundingCube cube = NcSoundingQuery.pfcSoundingQueryByLatLon(StnPt.getReftime().getTime(),StnPt.getRangestarttime().getTime(), latLon, StnPt.getSndType(), NcSoundingLayer.DataType.ALLDATA, false, "-1");
if(cube != null&& cube.getSoundingProfileList().size()>0){
NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0);
List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
// Chin-T List<SoundingLayer> sndLyList = NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst);
if(rtnSndLst != null && rtnSndLst.size() > 0){
if(pickedStnInfo == ""){
//use as first stn to show
pickedStnInfo = StnPt.getStnDisplayInfo();
double[][] latLon = {{StnPt.getLatitude(), StnPt.getLongitude()}};
for(NsharpStationInfo.timeLineSpecific tmlinSpc: StnPt.getTimeLineSpList() ){
Timestamp rangeTime = tmlinSpc.getTiemLine();
String stnDispInfo = tmlinSpc.getDisplayInfo();
NcSoundingCube cube = NcSoundingQuery.pfcSoundingQueryByLatLon(StnPt.getReftime().getTime(),rangeTime.getTime(), latLon, StnPt.getSndType(), NcSoundingLayer.DataType.ALLDATA, false, "-1");
//System.out.println(stnDispInfo + " "+ rangeTime);
if(cube != null&& cube.getSoundingProfileList().size()>0){
NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0);
List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
// Chin-T List<SoundingLayer> sndLyList = NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst);
if(rtnSndLst != null && rtnSndLst.size() > 0){
//update sounding data so they can be used by Skewt Resource and PalletWindow
//we should not have to do this, if EDEX has done this correctly....
//sndLyList = NsharpDataHandling.updateObsSoundingDataForShow(sndLyList, (float)StnPt.getElevation());
//Remove sounding layers that not used by NSHARP
rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
//minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough
// We need at least 2 regular layers for plotting
if(rtnSndLst != null && rtnSndLst.size() > 4)
//TBD soundingLysLstMap.put(StnPt.getStnDisplayInfo(), rtnSndLst);
soundingLysLstMap.put(stnDispInfo, rtnSndLst);
//System.out.println(stnDispInfo + " with sound layer size of "+ rtnSndLst.size());
}
}
}
}
}*/
/*
* Chin, use sounding time range array to query.
* 2/14/2012
*/
public static void getPfcSndDataBySndTmRange(List<NsharpStationInfo> stnPtDataLineLst, Map<String, List<NcSoundingLayer>> soundingLysLstMap) {
String stnDispInfo = "";
NcSoundingCube cube;
for(NsharpStationInfo StnPt : stnPtDataLineLst){
//one StnPt represent one data time line
//NcSoundingProfile sndPf= PfcSoundingQuery.getPfcSndData(StnPt.getDatauri(),(float)StnPt.getLatitude(), (float)StnPt.getLongitude(), StnPt.getReftime(),
// StnPt.getRangestarttime(), PfcSoundingQuery.PfcSndType.NAMSND);
long[] rangeTimeArray = new long[StnPt.getTimeLineSpList().size()];
int i=0;
for(NsharpStationInfo.timeLineSpecific tmlinSpc: StnPt.getTimeLineSpList() ){
Timestamp rangeTime = tmlinSpc.getTiemLine();
rangeTimeArray[i]=rangeTime.getTime();
i++;
}
//chin for testing pfcSoundingQueryByLatLon()
//double[][] latLon = new double [1][2];
//latLon[0][0]=StnPt.getLatitude();
//latLon[0][1]=StnPt.getLongitude();
//cube = NcSoundingQuery.pfcSoundingQueryByLatLon(StnPt.getReftime().getTime(), rangeTimeArray[0],latLon , StnPt.getSndType(), NcSoundingLayer.DataType.ALLDATA, false, "-1");
//end test
cube = NcSoundingQuery.pfcSoundingQueryByRangeTimeArray(StnPt.getReftime().getTime(),
rangeTimeArray, StnPt.getLatitude(),StnPt.getLongitude(), StnPt.getSndType(), NcSoundingLayer.DataType.ALLDATA, false, "-1");
if(cube != null&& cube.getSoundingProfileList().size()>0){
for(NcSoundingProfile sndPf : cube.getSoundingProfileList()){
List<NcSoundingLayer> rtnSndLst = sndPf.getSoundingLyLst();
if(rtnSndLst != null && rtnSndLst.size() > 0){
rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
//minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough
// We need at least 2 regular layers for plotting
if(rtnSndLst != null && rtnSndLst.size() > 4){
stnDispInfo="NA";
for(int j=0; j < StnPt.getTimeLineSpList().size(); j++ ){
NsharpStationInfo.timeLineSpecific tmlinSpcj = StnPt.getTimeLineSpList().get(j);
//System.out.println("rtnSndTIme="+ sndPf.getFcsTime() + " requestTime"+j+"="+tmlinSpcj.getTiemLine().getTime());
if(tmlinSpcj.getTiemLine().getTime()== sndPf.getFcsTime()){
stnDispInfo = tmlinSpcj.getDisplayInfo();
break;
}
}
soundingLysLstMap.put(stnDispInfo, rtnSndLst);
//System.out.println(stnDispInfo + " with sound layer size of "+ rtnSndLst.size());
}
}
//update sounding data so they can be used by Skewt Resource and PalletWindow
//we should not have to do this, if EDEX has done this correctly....
//sndLyList = NsharpDataHandling.updateObsSoundingDataForShow(sndLyList, (float)StnPt.getElevation());
//Remove sounding layers that not used by NSHARP
rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation());
//minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough
// We need at least 2 regular layers for plotting
if(rtnSndLst != null && rtnSndLst.size() > 4)
soundingLysLstMap.put(StnPt.getStnDisplayInfo(), rtnSndLst);
//System.out.println(StnPt.getStnDisplayInfo() + " with sound layer size of "+ soundLyLst.size());
}
}
}

View file

@ -21,6 +21,7 @@ package gov.noaa.nws.ncep.ui.nsharp.menu;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingCube;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingModel;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile;
import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines;
import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants;
@ -44,6 +45,7 @@ import java.util.Map;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -69,6 +71,8 @@ public class ModelSoundingDialogContents {
private Text locationText;
private Label locationLbl;
private boolean timeLimit = false;
private NsharpLoadDialog ldDia;
private Font newFont;
private List<String> selectedFileList = new ArrayList<String>();
private List<String> selectedTimeList = new ArrayList<String>();
//private NcSoundingProfile.MdlSndType currentSndType = NcSoundingProfile.MdlSndType.NONE;
@ -78,10 +82,14 @@ public class ModelSoundingDialogContents {
private final String GOOD_STN_STR = " A good input looked like this:\n GAI or gai";
String gribDecoderName = NcSoundingQuery.NCGRIB_PLUGIN_NAME;
private String selectedModel=null;
private DBType currentDb = DBType.NCGRIB;
public enum LocationType {
LATLON, STATION
}
public enum DBType {
GRIB, NCGRIB
}
private LocationType currentLocType=LocationType.LATLON;
public LocationType getCurrentLocType() {
@ -95,12 +103,15 @@ public class ModelSoundingDialogContents {
public ModelSoundingDialogContents (Composite parent) {
this.parent = parent;
ldDia = NsharpLoadDialog.getAccess();
newFont = ldDia.getNewFont();
if( VizPerspectiveListener.getCurrentPerspectiveManager()!= null){
if(VizPerspectiveListener.getCurrentPerspectiveManager().getPerspectiveId().equals(NmapCommon.NatlCntrsPerspectiveID))
gribDecoderName = NcSoundingQuery.NCGRIB_PLUGIN_NAME;
else
gribDecoderName = NcSoundingQuery.GRIB_PLUGIN_NAME;
//for testing
//gribDecoderName = NcSoundingQuery.GRIB_PLUGIN_NAME;
//System.out.println("perspective id = " + VizPerspectiveListener.getCurrentPerspectiveManager().getPerspectiveId());
@ -115,6 +126,7 @@ public class ModelSoundingDialogContents {
//query using NcSoundingQuery class to query
NcSoundingTimeLines timeLines = NcSoundingQuery.mdlSoundingTimeLineQuery(selectedModel, gribDecoderName);
if(timeLines!= null && timeLines.getTimeLines() != null){
ldDia.startWaitCursor();
for(Object timeLine : timeLines.getTimeLines()){
Timestamp reftime = (Timestamp)timeLine;
if(reftime != null){
@ -128,6 +140,7 @@ public class ModelSoundingDialogContents {
}
}
ldDia.stopWaitCursor();
}
else
System.out.println("SQL: query return null");
@ -139,9 +152,13 @@ public class ModelSoundingDialogContents {
sndTimeList.removeAll();
if(timeLineToFileMap!=null)
timeLineToFileMap.clear();
int nameLen= Math.min(4, selectedModel.length());
String modelName= selectedModel.substring(0,nameLen);
//query using NcSoundingQuery to query
ldDia.startWaitCursor();
for(int i=0; i< selectedFlLst.size(); i++){
String fl = selectedFlLst.get(i);
long reftimeMs= NcSoundingQuery.convertRefTimeStr(fl);
NcSoundingTimeLines timeLines = NcSoundingQuery.mdlSoundingRangeTimeLineQuery(selectedModel, fl, gribDecoderName);
if(timeLines != null && timeLines.getTimeLines().length >0) {
for(Object obj : timeLines.getTimeLines()){
@ -150,8 +167,9 @@ public class ModelSoundingDialogContents {
//need to format rangestart to GMT time string. Timestamp.toString produce a local time Not GMT time
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis(rangestart.getTime());
String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
long vHour = (cal.getTimeInMillis()- reftimeMs)/3600000;
String gmtTimeStr = String.format("%1$ty%1$tm%1$td/%1$tHV%2$03d %3$s", cal, vHour,modelName);
//String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
if(sndTimeList.indexOf(gmtTimeStr) != -1){
// this indicate that gmtTimeStr is laready in the sndTimeList, then we dont need to add it to list again.
continue;
@ -173,16 +191,22 @@ public class ModelSoundingDialogContents {
}
}
}
ldDia.stopWaitCursor();
}
private void queryAndLoadData(boolean stnQuery) {
soundingLysLstMap.clear();
ldDia.startWaitCursor();
//Chin Note: Since NcGrib/Grib HDF5 data file is created based on a forecast time line, we can not query
// more than one time line at one time as Edex server just could not support such query at one shot.
//This is not the case of PFC sounding (modelsounding db). It has all time lines of one forecast report
// saved in one file. Therefore, PFC query is much faster.
for(String timeLine: selectedTimeList){
// avail file, ie. its refTime
String selectedFileStr = timeLineToFileMap.get(timeLine);
String rangeStartStr = NcSoundingQuery.convertSoundTimeDispStringToRangeStartTimeFormat(timeLine);
float[][] latLon = {{lat, lon}};
NcSoundingCube cube = NcSoundingQuery.mdlSoundingQueryByLatLon(selectedFileStr+":00:00",timeLine, latLon, gribDecoderName,selectedModel, false, "-1");
NcSoundingCube cube = NcSoundingQuery.mdlSoundingQueryByLatLon(selectedFileStr+":00:00",rangeStartStr, latLon, gribDecoderName,selectedModel, false, "-1");
if(cube != null && cube.getRtnStatus()== NcSoundingCube.QueryStatus.OK){
//System.out.println("mdlSoundingQueryByLatLon returnd ok");
@ -240,7 +264,7 @@ public class ModelSoundingDialogContents {
//return;
}
}
ldDia.stopWaitCursor();
NsharpSkewTDisplay renderableDisplay;
NsharpSkewTEditor skewtEdt = NsharpSkewTEditor.createOrOpenSkewTEditor();
renderableDisplay = (NsharpSkewTDisplay) skewtEdt.getActiveDisplayPane().getRenderableDisplay();
@ -253,7 +277,7 @@ public class ModelSoundingDialogContents {
stnInfo.setLongitude(lon);
skewRsc.addRsc(soundingLysLstMap, stnInfo);
skewRsc.setSoundingType(selectedModel);
NsharpSkewTEditor.bringSkewTEditorToTop();
}
private void createModelTypeList(){
if(modelTypeList!=null)
@ -262,27 +286,48 @@ public class ModelSoundingDialogContents {
sndTimeList.removeAll();
if(availableFileList!=null)
availableFileList.removeAll();
Object[] mdlNames = NcSoundingQuery.soundingModelNameQuery(gribDecoderName);
ldDia.startWaitCursor();
NcSoundingModel mdlNames = NcSoundingQuery.soundingModelNameQuery(gribDecoderName);
//System.out.println("return from NcSoundingQuery ");
if(mdlNames != null)
for(String MdlStr: mdlNames.getMdlList()){
//System.out.println("model name:"+MdlStr);
modelTypeList.add(MdlStr);
}
ldDia.stopWaitCursor();
}
/*
private void createModelTypeListOld(){
if(modelTypeList!=null)
modelTypeList.removeAll();
if(sndTimeList!=null)
sndTimeList.removeAll();
if(availableFileList!=null)
availableFileList.removeAll();
ldDia.startWaitCursor();
Object[] mdlNames = NcSoundingQuery.soundingModelNameQueryOld(gribDecoderName);
//System.out.println("return from NcSoundingQuery ");
if(mdlNames != null)
for(Object MdlStr: mdlNames){
//System.out.println("model name:"+MdlStr);
modelTypeList.add((String)MdlStr);
}
}
ldDia.stopWaitCursor();
}*/
public void createMdlDialogContents(){
selectedFileList.clear();
topGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
topGp.setLayout( new GridLayout( 2, false ) );
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.setShellSize(true);
ldDia.createSndTypeList(topGp);
modelTypeGp = new Group(topGp, SWT.SHADOW_ETCHED_IN);
modelTypeGp.setText("Model Type");
modelTypeGp.setFont(newFont);
modelTypeList = new org.eclipse.swt.widgets.List(modelTypeGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
modelTypeList.setBounds(modelTypeGp.getBounds().x, modelTypeGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.filelistHeight );
modelTypeList.setBounds(modelTypeGp.getBounds().x, modelTypeGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.listHeight );
//query to get and add available sounding models from DB
modelTypeList.setFont(newFont);
createModelTypeList();
/*
Object[] mdlNames = NcSoundingQuery.soundingModelNameQuery(gribDecoderName);
@ -304,33 +349,54 @@ public class ModelSoundingDialogContents {
} );
Group gribGp = new Group(topGp, SWT.SHADOW_ETCHED_IN);
gribGp.setText("Database");
gribGp.setFont(newFont);
gribGp.setLayout( new GridLayout( 2, false ) );
Button ncgribBtn = new Button(gribGp, SWT.RADIO | SWT.BORDER);
ncgribBtn.setText("NCGrib");
ncgribBtn.setEnabled( true );
ncgribBtn.setSelection(true);
if(currentDb == DBType.NCGRIB)
ncgribBtn.setSelection(true);
ncgribBtn.setFont(newFont);
ncgribBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
gribDecoderName = NcSoundingQuery.NCGRIB_PLUGIN_NAME;
//query to get and add available sounding models from DB
currentDb = DBType.NCGRIB;
createModelTypeList();
}
} );
Button gribBtn = new Button(gribGp, SWT.RADIO | SWT.BORDER);
gribBtn.setText("Grib");
gribBtn.setFont(newFont);
gribBtn.setEnabled( true );
if(currentDb == DBType.GRIB)
gribBtn.setSelection(true);
gribBtn.setBounds(modelTypeGp.getBounds().x+ NsharpConstants.btnGapX, ncgribBtn.getBounds().y + ncgribBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
gribBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
gribDecoderName = NcSoundingQuery.GRIB_PLUGIN_NAME;
//query to get and add available sounding models from DB
currentDb = DBType.GRIB;
createModelTypeList();
}
} );
timeBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
/*
Button ncgribTestBtn = new Button(gribGp, SWT.RADIO | SWT.BORDER);
ncgribTestBtn.setText("NCGribTest");
ncgribTestBtn.setEnabled( true );
ncgribTestBtn.setSelection(false);
ncgribTestBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
gribDecoderName = NcSoundingQuery.NCGRIB_PLUGIN_NAME;
//query to get and add available sounding models from DB
createModelTypeListOld();
}
} ); */
timeBtn = new Button(topGp, SWT.CHECK | SWT.BORDER);
timeBtn.setText("00Z and 12Z only");
timeBtn.setEnabled( true );
timeBtn.setFont(newFont);
//timeBtn.setBounds(modelTypeGp.getBounds().x+ NsharpConstants.btnGapX, modelTypeGp.getBounds().y + modelTypeGp.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
timeBtn.addListener( SWT.MouseUp, new Listener() {
@ -348,17 +414,19 @@ public class ModelSoundingDialogContents {
}
} );
bottomGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
bottomGp.setLayout( new GridLayout( 2, false ) );
//bottomGp = new Group(topGp,SWT.SHADOW_ETCHED_IN);
//bottomGp.setLayout( new GridLayout( 2, false ) );
availableFileGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN);
availableFileGp = new Group(topGp,SWT.SHADOW_ETCHED_IN);
availableFileGp.setText("Available Grid files:");
availableFileGp.setFont(newFont);
availableFileList = new org.eclipse.swt.widgets.List(availableFileGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
availableFileList.setBounds(availableFileGp.getBounds().x, availableFileGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.filelistHeight );
availableFileList.setBounds(availableFileGp.getBounds().x, availableFileGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.listHeight*32/5 );
availableFileList.setFont(newFont);
//create a selection listener to handle user's selection on list
availableFileList.addListener ( SWT.Selection, new Listener () {
private String selectedFile=null;
public void handleEvent (Event e) {
if (availableFileList.getSelectionCount() > 0 ) {
selectedFileList.clear();
@ -373,11 +441,13 @@ public class ModelSoundingDialogContents {
} );
//create Sounding Times widget list
sndTimeListGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN);
sndTimeListGp = new Group(topGp,SWT.SHADOW_ETCHED_IN);
sndTimeListGp.setText("Sounding Times:");
sndTimeListGp.setFont(newFont);
sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
sndTimeList.removeAll();
sndTimeList.setBounds(sndTimeListGp.getBounds().x, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight );
sndTimeList.setFont(newFont);
sndTimeList.setBounds(sndTimeListGp.getBounds().x, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight *32/5);
sndTimeList.addListener ( SWT.Selection, new Listener () {
private String selectedSndTime=null;
public void handleEvent (Event e) {
@ -394,14 +464,14 @@ public class ModelSoundingDialogContents {
}
});
locationMainGp= new Group(parent,SWT.SHADOW_ETCHED_IN);
locationMainGp.setLayout( new GridLayout( 2, false ) );
locationMainGp.setLayout( new GridLayout( 5, false ) );
locationMainGp.setText("Location");
//latlonBtn.setBounds(x, y, width, height);
//locationTypeGp = new Group(locationMainGp,SWT.SHADOW_ETCHED_IN);
locationMainGp.setFont(newFont);
latlonBtn = new Button(locationMainGp, SWT.RADIO | SWT.BORDER);
latlonBtn.setText("Lat/Lon ");
latlonBtn.setText("Lat/Lon");
latlonBtn.setFont(newFont);
latlonBtn.setEnabled(true);
//latlonBtn.setBounds(locationMainGp.getBounds().x+ NsharpConstants.btnGapX, locationMainGp.getBounds().y + NsharpConstants.labelGap, bottomGp.getBounds().width/2, NsharpConstants.btnHeight);
//latlonBtn.setBounds(locationMainGp.getBounds().x+ NsharpConstants.btnGapX, locationMainGp.getBounds().y + NsharpConstants.labelGap, 10, NsharpConstants.btnHeight);
latlonBtn.setSelection(true);
latlonBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
@ -410,9 +480,9 @@ public class ModelSoundingDialogContents {
}
} );
stationBtn = new Button(locationMainGp, SWT.RADIO | SWT.BORDER);
stationBtn.setText("Station ");
stationBtn.setText("Station");
stationBtn.setEnabled(true);
//stationBtn.setBounds(locationMainGp.getBounds().x+latlonBtn.getBounds().width+ NsharpConstants.btnGapX, latlonBtn.getBounds().y, bottomGp.getBounds().width/2,NsharpConstants.btnHeight);
stationBtn.setFont(newFont);
stationBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentLocType = LocationType.STATION;
@ -423,11 +493,13 @@ public class ModelSoundingDialogContents {
locationLbl = new Label(locationMainGp, SWT.NONE | SWT.BORDER);
//locationLbl.setBounds(latlonBtn.getBounds().x, latlonBtn.getBounds().y + latlonBtn.getBounds().height+ NsharpConstants.btnGapY, bottomGp.getBounds().width/2,NsharpConstants.btnHeight);
locationLbl.setText("Location:");
locationLbl.setFont(newFont);
locationText = new Text(locationMainGp, SWT.BORDER | SWT.SINGLE);
GridData data1 = new GridData (SWT.FILL,SWT.FILL, true, true);
locationText.setLayoutData (data1);
//locationText.setBounds(stationBtn.getBounds().x, locationLbl.getBounds().y,450,NsharpConstants.btnHeight);
locationText.setTextLimit(15);
locationText.setFont(newFont);
locationText.addListener (SWT.Verify, new Listener () {
public void handleEvent (Event e) {
String userInputStr = e.text;
@ -453,6 +525,7 @@ public class ModelSoundingDialogContents {
loadBtn = new Button(locationMainGp, SWT.PUSH);
loadBtn.setText("Load ");
loadBtn.setFont(newFont);
loadBtn.setEnabled( true );
loadBtn.setBounds(locationMainGp.getBounds().x+ NsharpConstants.btnGapX, locationLbl.getBounds().y + locationLbl.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
loadBtn.addListener( SWT.MouseUp, new Listener() {
@ -524,6 +597,21 @@ public class ModelSoundingDialogContents {
}
}
} );
/*newTabBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
newTabBtn.setText("new skewT editor");
newTabBtn.setEnabled( true );
//newTabBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
newTabBtn.setFont(newFont);
newTabBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(newTabBtn.getSelection())
newtab = true;
else
newtab = false;
}
} );
*/
}
public void cleanup(){
@ -562,18 +650,15 @@ public class ModelSoundingDialogContents {
modelTypeGp.dispose();
modelTypeGp = null;
}
if(timeBtn != null){
timeBtn.removeListener(SWT.MouseUp, timeBtn.getListeners(SWT.MouseUp)[0]);
timeBtn.dispose();
timeBtn = null;
}
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.cleanSndTypeList();
if(topGp!= null){
topGp.dispose();
topGp = null;
}
if(timeBtn != null){
timeBtn.removeListener(SWT.MouseUp, timeBtn.getListeners(SWT.MouseUp)[0]);
timeBtn.dispose();
timeBtn = null;
}
@ -600,6 +685,11 @@ public class ModelSoundingDialogContents {
bottomGp.dispose();
bottomGp = null;
}
if(topGp!= null){
topGp.dispose();
topGp = null;
}
if(loadBtn != null){
loadBtn.removeListener(SWT.MouseUp, loadBtn.getListeners(SWT.MouseUp)[0]);
loadBtn.dispose();
@ -629,5 +719,11 @@ public class ModelSoundingDialogContents {
locationMainGp.dispose();
locationMainGp = null;
}
/*if(newTabBtn != null){
newTabBtn.removeListener(SWT.MouseUp, newTabBtn.getListeners(SWT.MouseUp)[0]);
newTabBtn.dispose();
newTabBtn = null;
}*/
}
}

View file

@ -205,7 +205,6 @@ public class NsharpHandleArchiveFile {
}
//System.out.println("total line " + i);
//System.out.println("time line " + timeLine + " stn disp info = " + stnDispInfo);
//Chin do we need this???? TBD timeList.add(timeLine);
if(sndLyList.size()> 0)
//Remove sounding layers that not used by NSHARP, and assume first layer is sfc layer from input data
sndLyList = NsharpDataHandling.organizeSoundingDataForShow(sndLyList, sndLyList.get(0).getGeoHeight());

View file

@ -28,7 +28,11 @@ import gov.noaa.nws.ncep.ui.nsharp.skewt.rsc.NsharpSkewTResource;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
@ -42,7 +46,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
public class NsharpLoadDialog extends Dialog {
private final static int DIALOG_WIDTH = 350;
private final static int DIALOG_HEIGHT = 620;
private final static int DIALOG_HEIGHT = 920;
protected Composite top;
private static Composite dialogParent;
@ -50,14 +54,14 @@ public class NsharpLoadDialog extends Dialog {
private static Shell shell;
private org.eclipse.swt.widgets.List soundingTypeList;
public static final String[] soundingTypeStringArray = {
"Observed Soundings" , "Model Soundings", "PFC Soundings", "ACARS Soundings", "Archive Files"
"Observed Soundings" , "Model Soundings", "PFC Soundings", "Archive Files","ACARS Soundings"
};
// define index to loadStringArray
public static final int OBSER_SND = 0;
public static final int MODEL_SND = 1;
public static final int PFC_SND = 2;
public static final int ACARS_SND = 3;
public static final int ARCHIVE = 4;
public static final int ARCHIVE = 3;
public static final int ACARS_SND = 4;
private ObservedSoundingDialogContents obsDialog;
private PfcSoundingDialogContents pfcDialog;
private ModelSoundingDialogContents mdlDialog;
@ -65,8 +69,12 @@ public class NsharpLoadDialog extends Dialog {
private int activeLoadSoundingType;
private Text text1;
private MessageBox mb;
private Cursor waitCursor=null;
private Font newFont;
public Font getNewFont() {
return newFont;
}
public ObservedSoundingDialogContents getObsDialog() {
return obsDialog;
}
@ -93,9 +101,11 @@ public class NsharpLoadDialog extends Dialog {
public void createSndTypeList(Group TopLoadGp) {
soundingTypeGp = new Group(TopLoadGp,SWT.SHADOW_ETCHED_IN);
soundingTypeGp.setText("Sounding Type");
soundingTypeGp.setFont(newFont);
soundingTypeList = new org.eclipse.swt.widgets.List(soundingTypeGp, SWT.SINGLE | SWT.V_SCROLL );
soundingTypeList.setBounds(soundingTypeGp.getBounds().x + NsharpConstants.btnGapX, soundingTypeGp.getBounds().y +NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight+30);
for(String loadStr : soundingTypeStringArray){
soundingTypeList.setBounds(soundingTypeGp.getBounds().x + NsharpConstants.btnGapX, soundingTypeGp.getBounds().y +NsharpConstants.labelGap, NsharpConstants.filelistWidth, NsharpConstants.listHeight);
soundingTypeList.setFont(newFont);
for(String loadStr : soundingTypeStringArray){
soundingTypeList.add( loadStr );
}
//create a selection listener to handle user's selection on list
@ -119,6 +129,7 @@ public class NsharpLoadDialog extends Dialog {
cleanupDialog(activeLoadSoundingType); //clean up before resetting activeLoadType
activeLoadSoundingType = OBSER_SND;
obsDialog.createObsvdDialogContents();
//shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
dialogParent.pack();
dialogParent.layout(true);
dialogParent.redraw();
@ -151,13 +162,24 @@ public class NsharpLoadDialog extends Dialog {
}
}
else if(selectedProduct.equals(soundingTypeStringArray[ARCHIVE])){
//System.out.println("ARCHIVE enter");
if(activeLoadSoundingType != ARCHIVE) {
cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType
activeLoadSoundingType = ARCHIVE;
NsharpHandleArchiveFile.openArchiveFile(shell);
close();
}
}
else if(selectedProduct.equals(soundingTypeStringArray[ACARS_SND])){
//System.out.println("ACARS_SND enter");
if(activeLoadSoundingType != ACARS_SND) {
cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType
activeLoadSoundingType = ACARS_SND;
setShellSize(false);
//setShellSize(false);
acarsGp = new Group(dialogParent,SWT.SHADOW_ETCHED_IN);
acarsGp.setLayout( new GridLayout( 1, false ) );
createSndTypeList(acarsGp);
@ -170,18 +192,6 @@ public class NsharpLoadDialog extends Dialog {
}
}
else if(selectedProduct.equals(soundingTypeStringArray[ARCHIVE])){
//System.out.println("ARCHIVE enter");
if(activeLoadSoundingType != ARCHIVE) {
cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType
activeLoadSoundingType = ARCHIVE;
NsharpHandleArchiveFile.openArchiveFile(shell);
close();
}
}
}
}
});
@ -257,7 +267,7 @@ public class NsharpLoadDialog extends Dialog {
//System.out.println("loadDia constructed");
activeLoadSoundingType = OBSER_SND;
}
/*
@ -269,13 +279,20 @@ public class NsharpLoadDialog extends Dialog {
protected void configureShell( Shell shell ) {
super.configureShell( shell );
NsharpLoadDialog.shell = shell;
setShellSize(false);
shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
shell.setText( "Load" );
mb = new MessageBox(shell, SWT.ICON_WARNING
| SWT.OK);
mb.setMessage( "User Input Error!");
Font font = shell.getFont();
FontData[] fontData = font.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setHeight(7);
//fontData[i].setName("courier");
}
newFont = new Font(font.getDevice(), fontData);
shell.setFont(newFont);
}
private void createLoadContents(Composite parent) {
@ -287,100 +304,24 @@ public class NsharpLoadDialog extends Dialog {
rsc.cleanUpRsc();
editor.refresh();
}
//System.out.println("createLoadContents called");
//NsharpMapModalTool.setModal();
//nsharpMapResource.
dialogParent = parent;
/*
topLoadGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
topLoadGp.setLayout( new GridLayout( 2, false ) );
createSndTypeList(topLoadGp);
*/
//dialogParent.setBounds(x, y, width, height);
obsDialog = new ObservedSoundingDialogContents(dialogParent);
pfcDialog = new PfcSoundingDialogContents(dialogParent);
mdlDialog = new ModelSoundingDialogContents(dialogParent);
obsDialog.createObsvdDialogContents();
//mdlDialog.createMdlDialogContents();
// set default selection to observed sounding
soundingTypeList.setSelection(0);
activeLoadSoundingType = OBSER_SND;
//soundingTypeList.setSelection(MODEL_SND);
//activeLoadType = MODEL_SND;
/*
//create a selection listener to handle user's selection on list
soundingTypeList.addListener ( SWT.Selection, new Listener () {
private String selectedProduct=null;
public void handleEvent (Event e) {
if (soundingTypeList.getSelectionCount() > 0 ) {
selectedProduct = soundingTypeList.getSelection()[0];
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if(selectedProduct.equals(soundingTypeStringArray[OBSER_SND])){
//System.out.println("OBSER_SND enter");
if(activeLoadType != OBSER_SND){
cleanupDialog(activeLoadType); //clean up before resetting activeLoadType
activeLoadType = OBSER_SND;
obsDialog.createObsvdDialogContents();
dialogParent.pack();
dialogParent.layout(true);
dialogParent.redraw();
}
}
else if(selectedProduct.equals(soundingTypeStringArray[MODEL_SND])){
//System.out.println("MODEL_SND enter");
if(activeLoadType != MODEL_SND) {
cleanupDialog(activeLoadType);//clean up before resetting activeLoadType
activeLoadType = MODEL_SND;
mdlDialog.createMdlDialogContents();
dialogParent.pack();
dialogParent.layout(true);
dialogParent.redraw();
}
}
else if(selectedProduct.equals(soundingTypeStringArray[PFC_SND])){
//System.out.println("PFC_SND enter");
if(activeLoadType != PFC_SND){
cleanupDialog(activeLoadType); //clean up before resetting activeLoadType
activeLoadType = PFC_SND;
pfcDialog.createPfcDialogContents();
dialogParent.pack();
dialogParent.layout(true);
dialogParent.redraw();
}
}
else if(selectedProduct.equals(soundingTypeStringArray[ACARS_SND])){
//System.out.println("ACARS_SND enter");
if(activeLoadType != ACARS_SND) {
cleanupDialog(activeLoadType);//clean up before resetting activeLoadType
activeLoadType = ACARS_SND;
//Not supported now!!
text1 = new Text(topLoadGp, SWT.MULTI | SWT.BORDER | SWT.WRAP );
text1.setText("Acars Soundings\nis still under\ndevelopment!");
topLoadGp.pack();
topLoadGp.layout(true);
topLoadGp.redraw();
}
}
else if(selectedProduct.equals(soundingTypeStringArray[ARCHIVE])){
//System.out.println("ARCHIVE enter");
if(activeLoadType != ARCHIVE) {
cleanupDialog(activeLoadType);//clean up before resetting activeLoadType
activeLoadType = ARCHIVE;
NsharpHandleArchiveFile.openArchiveFile(shell);
close();
}
}
}
}
});*/
switch(activeLoadSoundingType){
case MODEL_SND:
mdlDialog.createMdlDialogContents();
break;
case PFC_SND:
pfcDialog.createPfcDialogContents();
break;
default: //OBSER_SND is default for all other cases, also set activeLoadSoundingType to OBSER_SND
obsDialog.createObsvdDialogContents();
activeLoadSoundingType = OBSER_SND;
break;
}
soundingTypeList.setSelection(activeLoadSoundingType);
}
@ -397,11 +338,13 @@ public class NsharpLoadDialog extends Dialog {
mainLayout.marginHeight = 3;
mainLayout.marginWidth = 3;
top.setLayout(mainLayout);
//top.setLayout(mainLayout);
//System.out.println("createDialogArea called");
// Initialize all of the menus, controls, and layouts
createLoadContents(top);
shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
if(waitCursor==null)
waitCursor = new Cursor( top.getDisplay(), SWT.CURSOR_WAIT);
return top;
}
@ -427,9 +370,14 @@ public class NsharpLoadDialog extends Dialog {
//System.out.println("loadDia closed");
cleanSelf();
cleanupDialog(activeLoadSoundingType);
INSTANCE = null;
//INSTANCE = null;
if(waitCursor!=null)
waitCursor.dispose();
waitCursor=null;
newFont.dispose();
return (super.close());
}
public boolean closeDiaOnly() {
cleanSelf();
return (super.close());
@ -438,9 +386,14 @@ public class NsharpLoadDialog extends Dialog {
//Only use Cancel button but NOT ok button
@Override
public void createButtonsForButtonBar(Composite parent) {
// create Cancel buttons by default, but use close label
createButton(parent, IDialogConstants.CANCEL_ID,
Button cancelBtn = createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CLOSE_LABEL, false);
//cancelBtn.setBounds(cancelBtn.getBounds().x, cancelBtn.getBounds().y+DIALOG_HEIGHT, 20, 10);
//System.out.println("createButtonsForButtonBar cancelBtn bound"+cancelBtn.getBounds());
}
@ -460,13 +413,19 @@ public class NsharpLoadDialog extends Dialog {
}
public void setShellSize(boolean big){
if(big == true) {
shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
}
else {
shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT-100);
}
//public void setShellSize(boolean big){
// if(big == true) {
// }
// else {
// shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT-100);
// }
//}
public void startWaitCursor(){
if(waitCursor!=null)
top.setCursor(waitCursor);
}
public void stopWaitCursor(){
top.setCursor(null);
}
}

View file

@ -36,6 +36,8 @@ import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@ -46,19 +48,19 @@ import org.eclipse.swt.widgets.Listener;
public class ObservedSoundingDialogContents {
private Composite parent;
private org.eclipse.swt.widgets.List sndTimeList;
private Group btnGp, sndTimeListGp, topGp;
private boolean timeLimit = false;
private Group btnGp, sndTimeListGp, topGp, midGp;
private boolean timeLimit = false, newtab=false;
private boolean rawData = false;
private Button timeBtn, browseBtn, tamBtn, bufruaBtn, uairBtn, rawBtn;//, ncuairBtn;
private Button timeBtn, browseBtn, tamBtn, bufruaBtn, uairBtn, rawBtn, newTabBtn;
private String FILE_UAIR = "UAIR";
private String FILE_BUFRUA = "BUFRUA";
//private String FILE_DROP = "DROP";
private String FILE_TAMDAR = "TAMDAR";
private String FILE_BROWSE = "BROWSE";
private NcSoundingProfile.ObsSndType currentSndType = NcSoundingProfile.ObsSndType.NONE;
private NsharpLoadDialog ldDia;
private List<String> selectedTimeList = new ArrayList<String>();
private Font newFont;
public boolean isRawData() {
return rawData;
}
@ -67,21 +69,25 @@ public class ObservedSoundingDialogContents {
}
public ObservedSoundingDialogContents(Composite parent) {
this.parent = parent;
ldDia = NsharpLoadDialog.getAccess();
newFont = ldDia.getNewFont();
}
private void createObsvdSndUairList() {
sndTimeList.removeAll();
// use NcSoundingQuery to query
NcSoundingTimeLines timeLines = NcSoundingQuery.soundingTimeLineQuery(currentSndType.toString());
if(timeLines!= null && timeLines.getTimeLines() != null){
ldDia.startWaitCursor();
for(Object timeLine : timeLines.getTimeLines()){
Timestamp synoptictime = (Timestamp)timeLine;
if(synoptictime != null){
//need to format synoptictime to GMT time string. Timestamp.toString produce a local time Not GMT time
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis(synoptictime.getTime());
String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
String gmtTimeStr = String.format("%1$ty%1$tm%1$td/%1$tH", cal);
//String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
//System.out.println("GMT time " + gmtTimeStr + " msec="+ synoptictime.getTime() + " local time "+synoptictime.toString());
if(!timeLimit){
//System.out.println("not 00z and 12z only");
@ -95,18 +101,21 @@ public class ObservedSoundingDialogContents {
}
}
}
ldDia.stopWaitCursor();
}
else
System.out.println("EDEX timeline query return null");
}
private void queryAndMarkStn(String selectedSndTime) {
String selectTimetr = NcSoundingQuery.convertSoundTimeDispStringToRangeStartTimeFormat(selectedSndTime);
NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();
float lat, lon;
//Chin float lat, lon;
double lat, lon;
String stnInfoStr;
//use NcSoundingQuery to query stn info
NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery.soundingStnInfoQuery(currentSndType.toString(),selectedSndTime);
NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery.soundingStnInfoQuery(currentSndType.toString(),selectTimetr);
if(sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null){
NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo();
@ -130,6 +139,7 @@ public class ObservedSoundingDialogContents {
stn.setLatitude(lat);
//stn.setElevation(elv);
stn.setReftime(synoptictime);
stn.setRangestarttime(synoptictime);
stn.setSndType(currentSndType.toString());
//System.out.println("sndType= "+currentSndType);
//System.out.println("stn lat ="+stn.getLatitude() + " lon="+stn.getLongitude());
@ -157,18 +167,18 @@ public class ObservedSoundingDialogContents {
rawData = false;
topGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
topGp.setLayout( new GridLayout( 2, false ) );
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.setShellSize(false);
//ldDia.setShellSize(false);
ldDia.createSndTypeList(topGp);
btnGp = new Group(topGp, SWT.SHADOW_ETCHED_IN);
btnGp.setText("File Type");
btnGp.setFont(newFont);
uairBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER);
uairBtn.setText(FILE_UAIR);
uairBtn.setEnabled( true );
uairBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, btnGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
uairBtn.setFont(newFont);
uairBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
sndTimeList.removeAll();
@ -182,7 +192,7 @@ public class ObservedSoundingDialogContents {
bufruaBtn.setText(FILE_BUFRUA);
bufruaBtn.setEnabled( true );
bufruaBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, uairBtn.getBounds().y + uairBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
bufruaBtn.setFont(newFont);
bufruaBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
sndTimeList.removeAll();
@ -216,13 +226,13 @@ public class ObservedSoundingDialogContents {
sndTimeList.removeAll();
currentSndType = NcSoundingProfile.ObsSndType.DROP;
}
} ); */
} );
tamBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER);
tamBtn.setText(FILE_TAMDAR);
tamBtn.setEnabled( false );
tamBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, bufruaBtn.getBounds().y + bufruaBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
//tamBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, ncuairBtn.getBounds().y + ncuairBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
tamBtn.setFont(newFont);
tamBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
sndTimeList.removeAll();
@ -233,19 +243,20 @@ public class ObservedSoundingDialogContents {
browseBtn.setText(FILE_BROWSE);
browseBtn.setEnabled( false );
browseBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, tamBtn.getBounds().y + tamBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
browseBtn.setFont(newFont);
browseBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
sndTimeList.removeAll();
currentSndType = NcSoundingProfile.ObsSndType.BROWSE;
}
} );
timeBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
} ); */
midGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
midGp.setLayout( new GridLayout( 2, false ) );
timeBtn = new Button(midGp, SWT.CHECK | SWT.BORDER);
timeBtn.setText("00Z and 12Z only");
timeBtn.setEnabled( true );
//timeBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
timeBtn.setFont(newFont);
timeBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(timeBtn.getSelection())
@ -261,9 +272,12 @@ public class ObservedSoundingDialogContents {
}
} );
rawBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
rawBtn = new Button(midGp, SWT.CHECK | SWT.BORDER);
rawBtn.setText("raw data");
rawBtn.setEnabled( true );
rawBtn.setBounds(timeBtn.getBounds().x+timeBtn.getBounds().width, timeBtn.getBounds().y,
timeBtn.getBounds().width, timeBtn.getBounds().height);
rawBtn.setFont(newFont);
rawBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(rawBtn.getSelection())
@ -275,9 +289,11 @@ public class ObservedSoundingDialogContents {
//create file widget list
sndTimeListGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
sndTimeListGp.setText("Sounding Times:");
sndTimeListGp.setFont(newFont);
sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
sndTimeList.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight );
//create a selection listener to handle user's selection on list
sndTimeList.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight*7 );
sndTimeList.setFont(newFont);
//create a selection listener to handle user's selection on list
sndTimeList.addListener ( SWT.Selection, new Listener () {
private String selectedSndTime=null;
public void handleEvent (Event e) {
@ -285,16 +301,32 @@ public class ObservedSoundingDialogContents {
NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource();
nsharpMapResource.setPoints(null);
selectedTimeList.clear();
ldDia.startWaitCursor();
for(int i=0; i < sndTimeList.getSelectionCount(); i++) {
selectedSndTime = sndTimeList.getSelection()[i];
//System.out.println("selected sounding time is " + selectedSndTime);
queryAndMarkStn(selectedSndTime);
selectedTimeList.add(selectedSndTime);
}
ldDia.stopWaitCursor();
//NsharpMapMouseHandler.getAccess().setSelectedTimeList(selectedTimeList);
}
}
});
/*newTabBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
newTabBtn.setText("new skewT editor");
newTabBtn.setEnabled( true );
//newTabBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
newTabBtn.setFont(newFont);
newTabBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(newTabBtn.getSelection())
newtab = true;
else
newtab = false;
}
} ); */
}
public void cleanup(){
if(sndTimeList != null){
@ -316,7 +348,11 @@ public class ObservedSoundingDialogContents {
rawBtn.dispose();
rawBtn= null;
}
if(browseBtn != null){
if(midGp!= null){
midGp.dispose();
midGp = null;
}
/*if(browseBtn != null){
browseBtn.removeListener(SWT.MouseUp, browseBtn.getListeners(SWT.MouseUp)[0]);
browseBtn.dispose();
browseBtn = null;
@ -328,11 +364,7 @@ public class ObservedSoundingDialogContents {
tamBtn.dispose();
tamBtn = null;
}
/*if(ncuairBtn != null){
ncuairBtn.removeListener(SWT.MouseUp, ncuairBtn.getListeners(SWT.MouseUp)[0]);
ncuairBtn.dispose();
ncuairBtn = null;
}*/
*/
if(bufruaBtn != null){
bufruaBtn.removeListener(SWT.MouseUp, bufruaBtn.getListeners(SWT.MouseUp)[0]);
bufruaBtn.dispose();
@ -347,6 +379,11 @@ public class ObservedSoundingDialogContents {
btnGp.dispose();
btnGp = null;
}
/*if(newTabBtn != null){
newTabBtn.removeListener(SWT.MouseUp, newTabBtn.getListeners(SWT.MouseUp)[0]);
newTabBtn.dispose();
newTabBtn = null;
}*/
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.cleanSndTypeList();
if(topGp!= null){

View file

@ -35,6 +35,7 @@ import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@ -46,12 +47,14 @@ public class PfcSoundingDialogContents {
private Composite parent;
private org.eclipse.swt.widgets.List availablefileList, sndTimeList;
private Group topGp, fileTypeGp, bottomGp, availableFileGp, sndTimeListGp;
private Button namBtn, gfsBtn, ruc2Btn, rucpBtn, browseBtn,timeBtn;
private boolean timeLimit = false;
private Button namBtn, gfsBtn, newTabBtn,timeBtn;
private boolean timeLimit = false, newtab=false;
private List<String> selectedFileList = new ArrayList<String>();
private List<String> selectedTimeList = new ArrayList<String>();
private List<String> queriedTimeList = new ArrayList<String>();
private List<NsharpStationInfo> stnPoints = new ArrayList<NsharpStationInfo>();
private NcSoundingProfile.PfcSndType currentSndType = NcSoundingProfile.PfcSndType.NONE;
private NsharpLoadDialog ldDia;
private Font newFont;
public NcSoundingProfile.PfcSndType getCurrentSndType() {
return currentSndType;
}
@ -59,7 +62,8 @@ public class PfcSoundingDialogContents {
}
public PfcSoundingDialogContents (Composite parent) {
this.parent = parent;
ldDia = NsharpLoadDialog.getAccess();
newFont = ldDia.getNewFont();
}
private void createPFCAvailableFileList() {
sndTimeList.removeAll();;
@ -67,6 +71,7 @@ public class PfcSoundingDialogContents {
//query using NcSoundingQuery class to query
NcSoundingTimeLines timeLines = NcSoundingQuery.soundingTimeLineQuery(currentSndType.toString());
if(timeLines!= null && timeLines.getTimeLines() != null){
ldDia.startWaitCursor();
for(Object timeLine : timeLines.getTimeLines()){
Timestamp reftime = (Timestamp)timeLine;
if(reftime != null){
@ -80,6 +85,7 @@ public class PfcSoundingDialogContents {
}
}
ldDia.stopWaitCursor();
}
else
System.out.println("SQL: query return null");
@ -90,9 +96,15 @@ public class PfcSoundingDialogContents {
//currentDBTblName = MODELSOUNDING_TBL_NAME;
sndTimeList.removeAll();
//query using NcSoundingQuery to query
ldDia.startWaitCursor();
String sndStr = currentSndType.toString();
int endIndex= Math.min(3, sndStr.length());
String dispSndStr = sndStr.substring(0, endIndex);
for(int i=0; i< selectedFlLst.size(); i++){
String fl = selectedFlLst.get(i);
NcSoundingTimeLines timeLines = NcSoundingQuery.soundingRangeTimeLineQuery(currentSndType.toString(), fl);
long reftimeMs= NcSoundingQuery.convertRefTimeStr(fl);
//System.out.println("reftime="+fl + " in ms="+reftimeMs);
NcSoundingTimeLines timeLines = NcSoundingQuery.soundingRangeTimeLineQuery(sndStr, fl);
if(timeLines != null && timeLines.getTimeLines().length >0) {
for(Object obj : timeLines.getTimeLines()){
Timestamp rangestart = (Timestamp)obj;
@ -100,10 +112,13 @@ public class PfcSoundingDialogContents {
//need to format rangestart to GMT time string. Timestamp.toString produce a local time Not GMT time
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis(rangestart.getTime());
String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
long vHour = (cal.getTimeInMillis()- reftimeMs)/3600000;
//String sndType = currentSndType.toString().substring(0, 3); //use max of 3 char for sounding type
//String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", cal);
String gmtTimeStr = String.format("%1$ty%1$tm%1$td/%1$tHV%2$03d %3$s", cal, vHour,dispSndStr);
//gmtTimeStr = gmtTimeStr+ String.format("V%03d", vHour);
if(sndTimeList.indexOf(gmtTimeStr) != -1){
// this indicate that gmtTimeStr is laready in the sndTimeList, then we dont need to add it to list again.
// this indicate that gmtTimeStr is already in the sndTimeList, then we dont need to add it to list again.
continue;
}
@ -119,23 +134,24 @@ public class PfcSoundingDialogContents {
}
}
}
ldDia.stopWaitCursor();
}
public void createPfcDialogContents(){
selectedFileList.clear();
topGp = new Group(parent,SWT.SHADOW_ETCHED_IN);
topGp.setLayout( new GridLayout( 2, false ) );
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.setShellSize(false);
//ldDia.setShellSize(false);
ldDia.createSndTypeList(topGp);
fileTypeGp = new Group(topGp, SWT.SHADOW_ETCHED_IN);
fileTypeGp.setText("File Type");
fileTypeGp.setFont(newFont);
namBtn = new Button(fileTypeGp, SWT.RADIO | SWT.BORDER);
namBtn.setText("NAMSND");
namBtn.setEnabled( true );
namBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, fileTypeGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
namBtn.setFont(newFont);
namBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentSndType = NcSoundingProfile.PfcSndType.NAMSND;
@ -146,19 +162,19 @@ public class PfcSoundingDialogContents {
gfsBtn.setText("GFSSND");
gfsBtn.setEnabled( true );
gfsBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, namBtn.getBounds().y + namBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
gfsBtn.setFont(newFont);
gfsBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentSndType = NcSoundingProfile.PfcSndType.GFSSND;
createPFCAvailableFileList();
}
} );
/*
ruc2Btn = new Button(fileTypeGp, SWT.RADIO | SWT.BORDER);
ruc2Btn.setText("RUC2SND");
ruc2Btn.setEnabled( false );
ruc2Btn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, gfsBtn.getBounds().y + gfsBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
ruc2Btn.setFont(newFont);
ruc2Btn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentSndType = NcSoundingProfile.PfcSndType.RUC2SND;
@ -169,7 +185,7 @@ public class PfcSoundingDialogContents {
rucpBtn.setText("RUCPTYPSND");
rucpBtn.setEnabled( false );
rucpBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, ruc2Btn.getBounds().y + ruc2Btn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
rucpBtn.setFont(newFont);
rucpBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentSndType = NcSoundingProfile.PfcSndType.RUCPTYPSND;
@ -180,19 +196,19 @@ public class PfcSoundingDialogContents {
browseBtn.setText("BROWSE");
browseBtn.setEnabled( false );
browseBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, rucpBtn.getBounds().y + rucpBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
browseBtn.setFont(newFont);
browseBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
currentSndType = NcSoundingProfile.PfcSndType.BROWSE;
}
} );
} ); */
timeBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
timeBtn.setText("00Z and 12Z only");
timeBtn.setEnabled( true );
timeBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
//timeBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
timeBtn.setFont(newFont);
timeBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(timeLimit)
@ -201,7 +217,7 @@ public class PfcSoundingDialogContents {
timeLimit = true;
//refresh sounding list if file type is selected already
if(!currentSndType.equals("NA") && selectedFileList.size() > 0){
if(!currentSndType.equals("NA") && selectedFileList.size() > 0 ){
createPFCSndTimeList(selectedFileList);
}
@ -213,9 +229,11 @@ public class PfcSoundingDialogContents {
availableFileGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN);
availableFileGp.setText("Available PFC files:");
availableFileGp.setFont(newFont);
availablefileList = new org.eclipse.swt.widgets.List(availableFileGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
availablefileList.setBounds(availableFileGp.getBounds().x, availableFileGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.filelistHeight );
//create a selection listener to handle user's selection on list
availablefileList.setBounds(availableFileGp.getBounds().x, availableFileGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.listHeight *36/5);
//create a selection listener to handle user's selection on list
availablefileList.setFont(newFont);
availablefileList.addListener ( SWT.Selection, new Listener () {
private String selectedFile=null;
@ -235,64 +253,110 @@ public class PfcSoundingDialogContents {
//create Sounding Times widget list
sndTimeListGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN);
sndTimeListGp.setText("Sounding Times:");
sndTimeListGp.setFont(newFont);
sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL );
sndTimeList.removeAll();
sndTimeList.setBounds(sndTimeListGp.getBounds().x, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight );
sndTimeList.setFont(newFont);
sndTimeList.setBounds(sndTimeListGp.getBounds().x, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight*36/5 );
sndTimeList.addListener ( SWT.Selection, new Listener () {
private String selectedSndTime=null;
public void handleEvent (Event e) {
if (sndTimeList.getSelectionCount() > 0 ) {
NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource();
nsharpMapResource.setPoints(null);
selectedTimeList.clear();
//.clear();
ldDia.startWaitCursor();
queriedTimeList.clear();
for(int i=0; i < sndTimeList.getSelectionCount(); i++) {
selectedSndTime = sndTimeList.getSelection()[i];
int endIndex = selectedSndTime.indexOf(" ");
selectedSndTime = selectedSndTime.substring(0, endIndex);
//System.out.println("selected sounding time is " + selectedSndTime);
queryAndMarkStn(selectedSndTime);
selectedTimeList.add(selectedSndTime);
//refTimeStr is same as "PFC file" name in Load dialog display
String refTimeStr=NcSoundingQuery.convertSoundTimeDispStringToRefTime(selectedSndTime);
//while rangeStartStr is same as "sounding Times
String rangeStartStr = NcSoundingQuery.convertSoundTimeDispStringToRangeStartTimeFormat(selectedSndTime);
if(queriedTimeList.contains(refTimeStr)== true){
addStnPtWithoutQuery(refTimeStr,rangeStartStr,selectedSndTime);
}
else {
queriedTimeList.add(refTimeStr);
queryAndMarkStn(refTimeStr,rangeStartStr,selectedSndTime);
}
}
//NsharpMapMouseHandler.getAccess().setSelectedTimeList(selectedTimeList);
ldDia.stopWaitCursor();
nsharpMapResource.setPoints(stnPoints);
NsharpMapResource.bringMapEditorToTop();
}
}
});
/*
newTabBtn = new Button(parent, SWT.CHECK | SWT.BORDER);
newTabBtn.setText("new skewT editor");
newTabBtn.setEnabled( true );
//newTabBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight);
newTabBtn.setFont(newFont);
newTabBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if(newTabBtn.getSelection())
newtab = true;
else
newtab = false;
}
} );*/
}
private void queryAndMarkStn(String selectedSndTime) {
private void addStnPtWithoutQuery(String refTimeStr,String rangeStartStr, String selectedSndTime) {
long reftimeMs= NcSoundingQuery.convertRefTimeStr(refTimeStr);
Timestamp refTime = new Timestamp(reftimeMs);
for(NsharpStationInfo stn: stnPoints){
if(refTime.equals(stn.getReftime())== true){
long rangetimeMs= NcSoundingQuery.convertRefTimeStr(rangeStartStr);
Timestamp rangeStartTime = new Timestamp(rangetimeMs);
NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific();
String sndTypeStr = currentSndType.toString();
int endIndex= Math.min(4, sndTypeStr.length());
String dispInfo = stn.getStnId()+ " " + selectedSndTime+" "+sndTypeStr.substring(0,endIndex);
timeLinsSpc.setDisplayInfo(dispInfo);
timeLinsSpc.setTiemLine(rangeStartTime);
stn.addToTimeLineSpList(timeLinsSpc);
}
}
//System.out.println("addStnPtWithoutQuery stn num ="+ stnPoints.size()+ " for pfc refTime(file) "+refTimeStr);
}
private void queryAndMarkStn(String refTimeStr,String rangeStartStr, String selectedSndTime) {
//use NcSoundingQuery to query stn info
NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery.soundingStnInfoQuery(currentSndType.toString(),selectedSndTime);
String sndTypeStr = currentSndType.toString();
NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery.soundingStnInfoQuery(sndTypeStr,rangeStartStr, refTimeStr);
if(sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null){
NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo();
NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource();
//System.out.println("queryAndMarkStn stn num ="+ stnInfoAry.length);
//Note: A same station may have many reports
//System.out.println("queryAndMarkStn stn num ="+ stnInfoAry.length+ " for pfc refTime(file) "+refTimeStr);
for(int i=0; i < stnInfoAry.length; i++){
NcSoundingStnInfo stnInfo = stnInfoAry[i];
NsharpStationInfo stn = new NsharpStationInfo();
stn.setStnDisplayInfo(stnInfo.getStnId() + " " + selectedSndTime);
NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific();
int endIndex= Math.min(4, sndTypeStr.length());
String dispInfo = stnInfo.getStnId() + " " + selectedSndTime+" "+sndTypeStr.substring(0,endIndex);
timeLinsSpc.setDisplayInfo(dispInfo);
timeLinsSpc.setTiemLine(stnInfo.getRangeStartTime());
stn.addToTimeLineSpList(timeLinsSpc);
stn.setLongitude(stnInfo.getStationLongitude());
stn.setLatitude(stnInfo.getStationLatitude());
stn.setReftime(stnInfo.getSynopTime());
stn.setRangestarttime(stnInfo.getRangeStartTime());
stn.setSndType(currentSndType.toString());
//System.out.println( " currentSndType "+currentSndType);
//stn.setElevation(stnInfo.getStationElevation());
nsharpMapResource.addPoint(stn);
stn.setStnId(stnInfo.getStnId());
stn.setSndType(sndTypeStr);
//if(i <10)
// System.out.println( "disP="+dispInfo+" refT= "+stnInfo.getSynopTime()+ " rangSt="+stnInfo.getRangeStartTime());
stnPoints.add(stn);
;
}
NsharpMapResource.bringMapEditorToTop();
/* Chin test if(NsharpMapResource.getMapEditor() != null){
NsharpMapResource.getMapEditor().refresh();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(NsharpMapResource.getMapEditor());
}
else{
//bring the MAP editor back to top
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(NmapUiUtils.findDisplayByName("Map"));
}*/
//NsharpMapModalTool.setModal();
}
}
@ -307,7 +371,7 @@ public class PfcSoundingDialogContents {
gfsBtn.dispose();
gfsBtn = null;
}
if(ruc2Btn != null){
/*if(ruc2Btn != null){
ruc2Btn.removeListener(SWT.MouseUp, ruc2Btn.getListeners(SWT.MouseUp)[0]);
ruc2Btn.dispose();
ruc2Btn = null;
@ -322,7 +386,7 @@ public class PfcSoundingDialogContents {
browseBtn.dispose();
browseBtn = null;
}
} */
NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess();
ldDia.cleanSndTypeList();
if(topGp!= null){
@ -365,5 +429,10 @@ public class PfcSoundingDialogContents {
bottomGp.dispose();
bottomGp = null;
}
/*if(newTabBtn != null){
newTabBtn.removeListener(SWT.MouseUp, newTabBtn.getListeners(SWT.MouseUp)[0]);
newTabBtn.dispose();
newTabBtn = null;
}*/
}
}

View file

@ -230,6 +230,67 @@ public class NsharpNative {
}
public static int MAX_CLOUD_LAYER=20;
//cloudTypeFM value defined in caveNsharp.c OVC=1, BKN=2, SCT=3*/
public static String[] CLOUD_TYPE = {"dummy","OVC", "BKN", "SCT"};
public static class CloudInfoStr extends Structure {
/* FM: Fred Mosher's Algorithm */
public int sizeFM;
public float[] preStartFM= new float[MAX_CLOUD_LAYER];
public float[] preEndFM= new float[MAX_CLOUD_LAYER];
public int[] cloudTypeFM= new int[MAX_CLOUD_LAYER];
/* CE: Chernykh and Eskridge Algorithm */
public int sizeCE;
public float[] preStartCE= new float[MAX_CLOUD_LAYER];
public float[] preEndCE= new float[MAX_CLOUD_LAYER];
public CloudInfoStr() {
super();
sizeFM=0;
sizeCE=0;
}
protected ByReference newByReference() { return new ByReference(); }
protected ByValue newByValue() { return new ByValue(); }
protected CloudInfoStr newInstance() { return new CloudInfoStr(); }
public static class ByReference extends CloudInfoStr implements Structure.ByReference {
}
public static class ByValue extends CloudInfoStr implements Structure.ByValue {
}
public int getSizeFM() {
return sizeFM;
}
public int[] getCloudTypeFM() {
return cloudTypeFM;
}
public int getSizeCE() {
return sizeCE;
}
public float[] getPreStartCE() {
return preStartCE;
}
public float[] getPreEndCE() {
return preEndCE;
}
public float[] getPreStartFM() {
return preStartFM;
}
public float[] getPreEndFM() {
return preEndFM;
}
}
public static class StormSlinkyStr extends Structure {
public int size;
public float tottim;
@ -241,16 +302,7 @@ public class NsharpNative {
super();
size=-1;
}
/// @param tsuv C type : float[200][2]
/*public StormSlinkyStr(int size, float tottim, float angl, float tsuv[]) {
super();
this.size = size;
this.tottim = tottim;
this.angl = angl;
if (tsuv.length != this.tsuv.length)
throw new java.lang.IllegalArgumentException("Wrong array size !");
this.tsuv = tsuv;
}*/
protected ByReference newByReference() { return new ByReference(); }
protected ByValue newByValue() { return new ByValue(); }
protected StormSlinkyStr newInstance() { return new StormSlinkyStr(); }
@ -307,6 +359,7 @@ public class NsharpNative {
void get_storm(FloatByReference speed, FloatByReference direction);
void set_storm(float speed, float direction);
void cave_visual1 ( float lower, float upper, float pres, float temp, float dwpt , NsharpLibrary.StormSlinkyStr stmSlinky);
void draw_Clouds( NsharpLibrary.CloudInfoStr cloudInfo );
//float cave_bulk_rich ( float lplpres, float bplus,FloatByReference brnshear );
float cave_bulk_rich2 ( FloatByReference brnshear );
float cave_ship();

View file

@ -398,5 +398,8 @@ public static final String OPC_MIXINGPRESSURE_MISSING = "Mixing Pressure
public static final String STORM_MOTION_VECTOR_BUNKERS_L = "Bunkers L Storm Motion Vector";
public static final String CORFIDI_VECTORS = "Corfidi Vectors";
public static final String HODOGRAPH = "Hodograph Trace";
public static final String EFFECTIVE_LAYER = "Effective Layer";
public static final String CLOUD = "Cloud";
public static final String WINDBARB = "WindBarb Density(min dist betw barbs, m)";
public static final int WINDBARB_DISTANCE_DEFAULT= 400; // in meters
}

View file

@ -0,0 +1,145 @@
package gov.noaa.nws.ncep.ui.nsharp.palette;
/**
*
* gov.noaa.nws.ncep.ui.nsharp.palette.NsharpConfigDialog
*
*
* This code has been developed by the NCEP-SIB for use in the AWIPS2 system.
*
* <pre>
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------- ------- -------- -----------
* 03/21/2012 229 Chin Chen Initial coding
*
* </pre>
*
* @author Chin Chen
* @version 1.0
*/
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
public class NsharpConfigDialog extends Dialog {
private Button graphBtn, lineBtn;
private static NsharpConfigDialog thisDialog=null;
private static NsharpGraphConfigDialog graphDialog = null;
private static NsharpLineConfigDialog lineDialog = null;
public NsharpConfigDialog(Shell parentShell) {
super(parentShell);
// TODO Auto-generated constructor stub
}
public NsharpConfigDialog(IShellProvider parentShell) {
super(parentShell);
// TODO Auto-generated constructor stub
}
public static NsharpConfigDialog getInstance( Shell parShell){
if ( thisDialog == null ){
thisDialog = new NsharpConfigDialog( parShell );
}
return thisDialog;
}
public void createDialogContents(Composite parent){
graphBtn = new Button(parent, SWT.PUSH);
graphBtn.setText("Parameters Selection");
graphBtn.setEnabled( true );
//graphBtn.setSize(btnWidth,pushbtnHeight);
graphBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
graphDialog = NsharpGraphConfigDialog.getInstance(shell);
if ( graphDialog != null ) {
lineBtn.setEnabled(false);
graphDialog.open();
lineBtn.setEnabled(true);
}
}
} );
lineBtn = new Button(parent, SWT.PUSH);
lineBtn.setText("Data Display");
lineBtn.setEnabled( true );
//lineBtn.setSize(btnWidth,pushbtnHeight);
lineBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
lineDialog = NsharpLineConfigDialog.getInstance(shell);
if ( lineDialog != null ) {
graphBtn.setEnabled(false);
lineDialog.open();
graphBtn.setEnabled(true);
}
}
} );
}
@Override
public Control createDialogArea(Composite parent) {
Composite top;
top = (Composite) super.createDialogArea(parent);
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 3;
mainLayout.marginWidth = 3;
top.setLayout(mainLayout);
// Initialize all of the menus, controls, and layouts
createDialogContents(top);
return top;
}
@Override
public void createButtonsForButtonBar(Composite parent) {
Button closeBtn = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
true);
closeBtn.addListener( SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
//System.out.println("OK listener is called");
//NsharpSkewTResource skewtRsc = NsharpSkewTEditor.getActiveNsharpEditor().getNsharpSkewTDescriptor().getSkewtResource();
close();
}
} );
}
@Override
protected void configureShell( Shell shell ) {
super.configureShell( shell );
shell.setText( "Nsharp Configuration" );
shell.setSize(250, 200);
}
@Override
public int open( ) {
if ( this.getShell() == null ){
this.create();
}
this.getShell().setLocation(this.getShell().getParent().getLocation().x+1100,
this.getShell().getParent().getLocation().y+200);
return super.open();
}
}

Some files were not shown because too many files have changed in this diff Show more