/*
* Copyright 1998-2009 University Corporation for Atmospheric Research/Unidata
*
* Portions of this software were developed by the Unidata Program at the
* University Corporation for Atmospheric Research.
*
* Access and use of this software shall impose the following obligations
* and understandings on the user. The user is granted the right, without
* any fee or cost, to use, copy, modify, alter, enhance and distribute
* this software, and any derivative works thereof, and its supporting
* documentation for any purpose whatsoever, provided that this entire
* notice appears in all copies of the software, derivative works and
* supporting documentation. Further, UCAR requests that the user credit
* UCAR/Unidata in any publications that result from the use of this
* software or in any product that includes this software. The names UCAR
* and/or Unidata, however, may not be used in any advertising or publicity
* to endorse or promote any products or commercial entity unless specific
* written permission is obtained from UCAR/Unidata. The user also
* understands that UCAR/Unidata is not obligated to provide the user with
* any support, consulting, training or assistance of any kind with regard
* to the use, operation and performance of this software nor to provide
* the user with any updates, revisions, new versions or "bug fixes."
*
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package ucar.unidata.geoloc.vertical;
import junit.framework.*;
import ucar.ma2.*;
import ucar.nc2.dataset.VerticalCT;
import ucar.nc2.TestAll;
import ucar.nc2.dt.GridDatatype;
import ucar.nc2.dt.GridDataset;
import ucar.nc2.dt.GridCoordSystem;
/**
* Test basic projection methods
*/
public class TestVertical extends TestCase {
public TestVertical(String name) {
super(name);
}
public void testOceanS() throws java.io.IOException, InvalidRangeException {
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(TestAll.cdmUnitTestDir + "transforms/roms_ocean_s_coordinate.nc");
GridDatatype grid = gds.findGridDatatype("temp");
assert grid != null;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalCT vct = gcs.getVerticalCT();
assert vct != null;
assert vct.getVerticalTransformType() == VerticalCT.Type.OceanS;
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
gds.close();
}
public void testOceanSigma() throws java.io.IOException, InvalidRangeException {
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestAll.cdmUnitTestDir + "conventions/cf/gomoos_cf.nc");
GridDatatype grid = gds.findGridDatatype("temp");
assert grid != null;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalCT vct = gcs.getVerticalCT();
assert vct != null;
assert vct.getVerticalTransformType() == VerticalCT.Type.OceanSigma;
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
gds.close();
}
public void testAtmSigma() throws java.io.IOException, InvalidRangeException {
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestAll.cdmUnitTestDir + "transforms/temperature.nc");
GridDatatype grid = gds.findGridDatatype("Temperature");
assert grid != null;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalCT vct = gcs.getVerticalCT();
assert vct != null;
assert vct.getVerticalTransformType() == VerticalCT.Type.Sigma;
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
gds.close();
}
public void testAtmHybrid() throws java.io.IOException, InvalidRangeException {
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestAll.cdmUnitTestDir + "conventions/cf/ccsm2.nc");
GridDatatype grid = gds.findGridDatatype("T");
assert grid != null;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalCT vct = gcs.getVerticalCT();
assert vct != null;
assert vct.getVerticalTransformType() == VerticalCT.Type.HybridSigmaPressure : vct.getVerticalTransformType();
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
gds.close();
}
public void testWrfEta() throws java.io.IOException, InvalidRangeException {
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestAll.cdmUnitTestDir + "conventions/wrf/wrfout_v2_Lambert.nc");
GridDatatype grid = gds.findGridDatatype("T");
assert grid != null;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalCT vct = gcs.getVerticalCT();
assert vct != null;
assert vct.getVerticalTransformType() == VerticalCT.Type.WRFEta : vct.getVerticalTransformType();
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
gds.close();
}
// TestAll.upcShareDir + /testdata2/grid/netcdf/wrf/wrfout_v2_Lambert.nc
public void utestStride() throws java.io.IOException, InvalidRangeException {
String url= "dods://lead4.unidata.ucar.edu:8080/thredds/dodsC/model/UCAR/UNIDATA/WRF/STEERED/wrfout_d01_2006-04-20_00_00_00.nc";
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( url);
GridDatatype grid = gds.findGridDatatype("T");
assert grid != null;
grid = grid.makeSubset(null,null,null,1,2,4);
GridCoordSystem gcs = grid.getCoordinateSystem();
assert gcs != null;
VerticalTransform vt = gcs.getVerticalTransform();
assert vt != null;
ArrayDouble.D3 ca = vt.getCoordinateArray(0);
assert ca != null;
assert ca.getRank() == 3 : ca.getRank();
int[] shape = ca.getShape();
for (int i = 0; i < 3; i++)
System.out.println(" shape " + i + " = " + shape[i]);
assert shape[0] == 30;
assert shape[1] == 143/2 + 1;
assert shape[2] == 143/4 + 1;
gds.close();
}
}