public boolean checkModisL1B() { Group modisl1bGroup = ncfile.findGroup("MODIS_SWATH_Type_L1B"); return modisl1bGroup != null; }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; Group loc = ncfile.findGroup("VHRR/Geo-Location"); if (null == loc) return false; if (null == loc.findVariable("Latitude")) return false; if (null == loc.findVariable("Longitude")) return false; return null != ncfile.findGroup("VHRR/Image Data"); }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; Group loc = ncfile.findGroup("VHRR/Geo-Location"); if (null == loc) return false; if (null == loc.findVariable("Latitude")) return false; if (null == loc.findVariable("Longitude")) return false; if (null == ncfile.findGroup("VHRR/Image Data")) return false; return true; }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; Group loc = ncfile.findGroup("VHRR/Geo-Location"); if (null == loc) return false; if (null == loc.findVariable("Latitude")) return false; if (null == loc.findVariable("Longitude")) return false; return null != ncfile.findGroup("VHRR/Image Data"); }
public void addScientificMetadata(Product product) throws ProductIOException { Group group = ncFile.findGroup("Scan-Line_Attributes"); if (group == null) { group = ncFile.findGroup("scan_line_attributes"); } if (group != null) { final MetadataElement scanLineAttrib = getMetadataElementSave(product, "Scan_Line_Attributes"); handleMetadataGroup(group, scanLineAttrib); } group = ncFile.findGroup("Sensor_Band_Parameters"); if (group == null) { group = ncFile.findGroup("sensor_band_parameters"); } if (group != null) { final MetadataElement sensorBandParam = getMetadataElementSave(product, "Sensor_Band_Parameters"); handleMetadataGroup(group, sensorBandParam); } }
/** * Defines the groups where to search for named attributes, in preference order. * The {@code null} group name stands for the global attributes. */ @Override public void setSearchPath(final String... groupNames) { final Group[] groups = new Group[groupNames.length]; int count = 0; for (final String name : groupNames) { if (name != null) { final Group group = file.findGroup(name); if (group == null) { continue; // Group not found - do not increment the counter. } groups[count] = group; } count++; } this.groups = ArraysExt.resize(groups, count); }
/** * Defines the groups where to search for named attributes, in preference order. * The {@code null} group name stands for the global attributes. */ @Override public void setSearchPath(final String... groupNames) { final Group[] groups = new Group[groupNames.length]; int count = 0; for (final String name : groupNames) { if (name != null) { final Group group = file.findGroup(name); if (group == null) { continue; // Group not found - do not increment the counter. } groups[count] = group; } count++; } this.groups = ArraysExt.resize(groups, count); }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; // Visible Infrared Imaging Radiometer Suite (VIIRS) Group loc = ncfile.findGroup("All_Data/VIIRS-MOD-GEO-TC_All"); if (loc == null) loc = ncfile.findGroup("All_Data/VIIRS-CLD-AGG-GEO_All"); // Cross-track Infrared Sounder (CrIS) // http://npp.gsfc.nasa.gov/cris.html if (loc == null) { loc = ncfile.findGroup("All_Data"); if (loc == null) return false; Attribute att = ncfile.findGlobalAttribute("Instrument_Name"); if ((att == null) || !att.getStringValue().equals("CrIS")) return false; if (null == loc.findVariable(PRESSURE_COORD_NAME)) return false; } return null != loc.findVariable("Latitude") && null != loc.findVariable("Longitude"); }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; // Visible Infrared Imaging Radiometer Suite (VIIRS) Group loc = ncfile.findGroup("All_Data/VIIRS-MOD-GEO-TC_All"); if (loc == null) loc = ncfile.findGroup("All_Data/VIIRS-CLD-AGG-GEO_All"); // Cross-track Infrared Sounder (CrIS) // http://npp.gsfc.nasa.gov/cris.html if (loc == null) { loc = ncfile.findGroup("All_Data"); Attribute att = ncfile.findGlobalAttribute("Instrument_Name"); if ((att == null) || !att.getStringValue().equals("CrIS")) return false; if (null == loc.findVariable(PRESSURE_COORD_NAME)) return false; } if (null == loc.findVariable("Latitude")) return false; if (null == loc.findVariable("Longitude")) return false; return true; }
public static boolean isMine(NetcdfFile ncfile) { if (!ncfile.getFileTypeId().equals("HDF5")) return false; // Visible Infrared Imaging Radiometer Suite (VIIRS) Group loc = ncfile.findGroup("All_Data/VIIRS-MOD-GEO-TC_All"); if (loc == null) loc = ncfile.findGroup("All_Data/VIIRS-CLD-AGG-GEO_All"); // Cross-track Infrared Sounder (CrIS) // http://npp.gsfc.nasa.gov/cris.html if (loc == null) { loc = ncfile.findGroup("All_Data"); if (loc == null) return false; Attribute att = ncfile.findGlobalAttribute("Instrument_Name"); if ((att == null) || !att.getStringValue().equals("CrIS")) return false; if (null == loc.findVariable(PRESSURE_COORD_NAME)) return false; } if (null == loc.findVariable("Latitude")) return false; return null != loc.findVariable("Longitude"); }
private void fixBandNames() { String navGroup = "Geophysical_Data"; List<Variable> variables = ncFile.findGroup(navGroup).getVariables(); String varName; for (Variable variable : variables) { varName = variable.getShortName().replace("L", "Lt"); variable.setName(varName); } }
public ProductType checkViirsXDR() { Attribute platformShortName = ncfile.findGlobalAttribute("Platform_Short_Name"); try { if (platformShortName.getStringValue().equals("NPP")) { Group dataProduct = ncfile.findGroup("Data_Products"); if (dataProduct.getGroups().get(0).getShortName().matches("VIIRS.*IP")) { return ProductType.VIIRS_IP; } if (dataProduct.getGroups().get(0).getShortName().matches("VIIRS.*SDR")) { return ProductType.VIIRS_SDR; } if (dataProduct.getGroups().get(0).getShortName().matches("VIIRS.*EDR")) { return ProductType.VIIRS_EDR; } if (dataProduct.getGroups().get(0).getShortName().matches("VIIRS.*GEO.*")) { return ProductType.VIIRS_GEO; } } } catch (Exception ignored) { } return ProductType.UNKNOWN; } private boolean checkHicoL1B() {
@Test public void problemHugeHeapId() throws IOException { //H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header")); String filename = TestH5.testDir + "SMAP_L4_SM_aup_20140115T030000_V05007_001.h5"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { Group g = ncfile.findGroup("Metadata"); assert g != null; Attribute att = g.findAttribute("iso_19139_dataset_xml"); assert att != null; assert att.isString(); String val = att.getStringValue(); System.out.printf(" len of %s is %d%n", att.getFullName(), val.length()); assert val.length() > 200 * 1000; // silly rabbit } }
@Test public void testGaussianLats() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/CCCma_SRES_A2_HGT500_1-10.grb"; System.out.println("\n\nReading File " + filename); NetcdfFile ncfile = NetcdfFile.open(filename); Group best = ncfile.findGroup("Best"); Variable lat = ncfile.findVariable(best, "lat"); assert lat.getSize() == 48; ncfile.close(); }
@Test public void testHybridCoordinates() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/07010418_arw_d01.GrbF01500"; System.out.println("\n\nReading File " + filename); NetcdfFile ncfile = NetcdfFile.open(filename); Group best = ncfile.findGroup("Best"); Variable hybrid = ncfile.findVariable(best, "hybrid1"); assert hybrid != null; assert (hybrid.getDimensions().size() == 1); Dimension d = hybrid.getDimension(0); assert (d.getLength() == 2); ncfile.close(); }
public void testHybrid1() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/HIRLAMhybrid.grib"; System.out.println("\n\nReading File " + filename); NetcdfFile ncfile = NetcdfFile.open(filename); Group best = ncfile.findGroup("Best"); Variable hybrid = ncfile.findVariable(best, "hybrid"); assert (hybrid.getNameAndDimensions().equals("hybrid(hybrid=91)")); Variable hybrida = ncfile.findVariable(best, "hybrida"); assert (hybrida.getNameAndDimensions().equals("hybrida(hybrid=91)")); Variable hybridb = ncfile.findVariable(best, "hybridb"); assert (hybridb.getNameAndDimensions().equals("hybridb(hybrid=91)")); int idx = hybrid.findDimensionIndex("hybrid"); Dimension dim = hybrid.getDimension(idx); assert dim.getShortName().equals("hybrid"); ncfile.close(); }
public void addMetadata(Product product, String groupname, String meta_element) throws ProductIOException { Group group = ncFile.findGroup(groupname); if (group != null) { final MetadataElement bandAttributes = new MetadataElement(meta_element); List<Variable> variables = group.getVariables(); for (Variable variable : variables) { final String name = variable.getShortName(); final MetadataElement sdsElement = new MetadataElement(name + ".attributes"); final int dataType = getProductDataType(variable); final MetadataAttribute prodtypeattr = new MetadataAttribute("data_type", dataType); sdsElement.addAttribute(prodtypeattr); bandAttributes.addElement(sdsElement); final List<Attribute> list = variable.getAttributes(); for (Attribute varAttribute : list) { addAttributeToElement(sdsElement, varAttribute); } } final MetadataElement metadataRoot = product.getMetadataRoot(); metadataRoot.addElement(bandAttributes); } }
Group best = ncf.findGroup("Best"); // use best group if it exists, may be null Variable var = ncf.findVariableByAttribute(best, Grib.VARIABLE_ID_ATTNAME, parameter); assert var != null : parameter;
@Category(NeedsCdmUnitTest.class) public void testEscaping() throws InvalidRangeException, IOException { NetcdfFile ncfile = NetcdfDataset.openDataset(TestDir.cdmUnitTestDir + "ncml/escapeNames.ncml"); Group g = ncfile.findGroup("group.name"); assert g != null; Variable v = g.findVariable("var.name"); assert v != null; Variable v2 = ncfile.findVariable("group.name/var.name"); assert v2 == null; v2 = ncfile.findVariable("group\\.name/var\\.name"); assert v2 != null; assert v2.equals(v); ParsedSectionSpec spec = ParsedSectionSpec.parseVariableSection(ncfile, "group\\.name/var\\.name"); System.out.printf("%s%n", spec); assert spec.section.equals(v2.getShapeAsSection()); spec = ParsedSectionSpec.parseVariableSection(ncfile, "group\\.name/var\\.name(1,0:0)"); System.out.printf("%s%n", spec); Section s = new Section("1,0"); assert spec.section.equals(s); ncfile.close(); }
@Category(NeedsCdmUnitTest.class) public void testEscaping2() throws InvalidRangeException, IOException { NetcdfFile ncfile = NetcdfDataset.openDataset(TestDir.cdmUnitTestDir + "ncml/escapeNames.ncml"); Group g = ncfile.findGroup("group(name"); assert g != null; Variable v = g.findVariable("var(name"); assert v != null; Variable v2 = ncfile.findVariable("group(name/var(name"); assert v2 != null; assert v2.equals(v); v2 = ncfile.findVariable("group\\(name/var\\(name"); assert v2 != null; assert v2.equals(v); ParsedSectionSpec spec = ParsedSectionSpec.parseVariableSection(ncfile, "group\\(name/var\\(name"); System.out.printf("%s%n", spec); assert spec.section.equals(v2.getShapeAsSection()); spec = ParsedSectionSpec.parseVariableSection(ncfile, "group\\(name/var\\(name(1,0:0)"); System.out.printf("%s%n", spec); Section s = new Section("1,0"); assert spec.section.equals(s); ncfile.close(); }