Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

Plume Driver beta #30

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions sensorhub-driver-nexrad/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sensorhub</groupId>
<artifactId>sensorhub-all</artifactId>
<version>1.0</version>
<relativePath>../sensorhub-all/pom.xml</relativePath>
</parent>
<artifactId>sensorhub-driver-nexrad</artifactId>
<version>0.1</version>
<name>Nexrad driver</name>
<description>Driver for Nexrad radar, supporting both Level II and Level III products</description>
<organization>
<name>Botts Inc.</name>
<url>http://www.botts-inc.com/</url>
</organization>
<developers>
<developer>
<id>tony.cook</id>
<name>Tony Cook</name>
<email>[email protected]</email>
</developer>
</developers>
<repositories>
<repository>
<id>unidata-releases</id>
<name>UNIDATA Releases</name>
<url>https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.sensorhub</groupId>
<artifactId>sensorhub-core</artifactId>
<version>1.0</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>cdm</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sensorhub.impl.sensor.nexrad;

public enum Level2Product {
REFLECTIVITY("Reflectivity"),
VELOCITY("RadialVelocity"),
SPECTRUM_WIDTH("SpectrumWidth");

private final String productStr;

private Level2Product(String s) {
this.productStr = s;
}

@Override
public String toString() {
return productStr;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package org.sensorhub.impl.sensor.nexrad;

import java.io.IOException;
import java.util.Date;
import java.util.Formatter;

import ucar.nc2.dt.RadialDatasetSweep;
import ucar.nc2.ft.FeatureDatasetFactoryManager;
import ucar.nc2.util.CancelTask;


/**
*<p>Title: Level2Reader.java</p>
* <p>Description: Read Level II archive format using UCAR libs into Sweeps and Radials</p>
* @author Tony Cook
* @since March 2015
*
* NOTE: a lot of the UCAR methods are deprecated. They are based on TypedDataset, which is deprecated.
* But RadialDatasetSweep extends TypedDataset and is not deprecated. Not worrying about it for now.
*/

public class Level2Reader {

public Sweep readSweep(String source, Level2Product prod) throws IOException{
return readSweep(source, prod.toString());
}

public Sweep readSweep(String source, String variableName) throws IOException{
// These used to be class vars- moved to this method since this is the only place they are being used
// If I need to provide more interactive progress feedback, these would need to be class vars again
RadialDatasetSweep radialDataset = null;
RadialDatasetSweep.RadialVariable radialVar = null;
Sweep sweep = new Sweep();

CancelTask cancelTask = new CancelTask() {
public boolean isCancel() {
return false;
}
public void setError(String msg) {
}
@Override
public void setProgress(String msg, int progress) {
}
};
Formatter formatter = new Formatter();

try {
radialDataset = (RadialDatasetSweep) FeatureDatasetFactoryManager.open(ucar.nc2.constants.FeatureType.RADIAL, source, cancelTask, formatter);
} catch (IOException e) {
e.printStackTrace();
}

// Get Radial Variable
// java.util.List<VariableSimpleIF> vars = radialDataset.getDataVariables();
radialVar = (RadialDatasetSweep.RadialVariable) radialDataset.getDataVariable(variableName);
if(radialVar == null) {
String vName = variableName + "_HI"; // Some files have _HI appended to the variable name
radialVar = (RadialDatasetSweep.RadialVariable) radialDataset.getDataVariable(vName);
if (radialVar == null) {
throw new IOException("The variable '"+ variableName+"' was not found.");
}
}
RadialDatasetSweep.Sweep rdsSweep = radialVar.getSweep(0);
int numRadials = rdsSweep.getRadialNumber();
for(int i=0; i<numRadials; i++) {
Radial r = new Radial();
r.azimuth = rdsSweep.getAzimuth(i);
r.elevation = rdsSweep.getElevation(i);
sweep.rangeToFirstGate = rdsSweep.getRangeToFirstGate();
sweep.gateSpacing = rdsSweep.getGateSize();
// r.radialStartTime = rdsSweep.getTime(i);
sweep.numGates = rdsSweep.getGateNumber();
r.dataFloat = rdsSweep.readData(i);
sweep.addRadial(r);
}

double rangeFoldedValue = Double.NEGATIVE_INFINITY;
Date dateTime = radialDataset.getStartDate();
long startTimeMs = dateTime.getTime();
sweep.setStartTimeMs(startTimeMs);

return sweep;
}

public static void main(String[] args) throws IOException {
String testFile = "C:/Data/sensorhub/Level2/HTX/KHTX20110427_205716_V03";
Level2Reader reader = new Level2Reader();
Sweep sweep = reader.readSweep(testFile, Level2Product.REFLECTIVITY);
// Sweep sweep = reader.readSweep(testFile, Level2Product.VELOCITY);
System.err.println(sweep);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2012-2015 Sensia Software LLC. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/

package org.sensorhub.impl.sensor.nexrad;

import org.sensorhub.api.sensor.SensorConfig;


public class NexradConfig extends SensorConfig
{
public double centerLatitude; // in deg
public double centerLongitude; // in deg
public double elevationMeters;

public static void main(String[] args) {
System.err.println("Build ME");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

The Initial Developer is Sensia Software LLC. Portions created by the Initial
Developer are Copyright (C) 2014 the Initial Developer. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/

package org.sensorhub.impl.sensor.nexrad;

import org.sensorhub.api.module.IModule;
import org.sensorhub.api.module.IModuleProvider;
import org.sensorhub.api.module.ModuleConfig;


public class NexradModuleDescriptor implements IModuleProvider
{

@Override
public String getModuleName()
{
return "Nexrad 88D Radar Network";
}


@Override
public String getModuleDescription()
{
return "Nexrad 88D Radar data- archive Level III for now. Realtime and Level II support forthcoming";
}


@Override
public String getModuleVersion()
{
return "0.1";
}


@Override
public String getProviderName()
{
return "Botts Innovative Research Inc";
}


@Override
public Class<? extends IModule<?>> getModuleClass()
{
return NexradSensor.class;
}


@Override
public Class<? extends ModuleConfig> getModuleConfigClass()
{
return NexradConfig.class;
}

}
Loading