-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SEADAS: seadas reader fixes (master) #119
Open
knowles
wants to merge
5
commits into
master
Choose a base branch
from
SEADAS-seadas-reader-fixes-master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
74a052c
L1AHawkeyeFileReader: fixed product naming
knowles 58d6924
seadas-reader: 1. recognizes level3 mapped files output by l3mapgen a…
knowles 1578441
seadas-reader: adding quality masks to level2 file reader
knowles 9694bdd
Merge branch 'SEADAS-L2QualityMasks-master' into SEADAS-seadas-reader…
knowles c79a22f
Merge branch 'SEADAS-PACE-L1C-L1B-V8-master' into SEADAS-seadas-reade…
knowles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
800 changes: 800 additions & 0 deletions
800
seadas-reader/src/main/java/gov/nasa/gsfc/seadas/dataio/L1CPaceFileReader.java
Large diffs are not rendered by default.
Oops, something went wrong.
179 changes: 179 additions & 0 deletions
179
seadas-reader/src/main/java/gov/nasa/gsfc/seadas/dataio/L1CPaceProductReaderPlugIn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
package gov.nasa.gsfc.seadas.dataio; | ||
|
||
import org.esa.snap.core.dataio.DecodeQualification; | ||
import org.esa.snap.core.dataio.ProductReader; | ||
import org.esa.snap.core.util.io.SnapFileFilter; | ||
import org.esa.snap.dataio.netcdf.GenericNetCdfReaderPlugIn; | ||
import org.esa.snap.dataio.netcdf.util.NetcdfFileOpener; | ||
import ucar.nc2.Attribute; | ||
import ucar.nc2.NetcdfFile; | ||
import ucar.nc2.iosp.hdf5.H5iosp; | ||
import ucar.nc2.util.DebugFlags; | ||
import ucar.nc2.util.DebugFlagsImpl; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
public class L1CPaceProductReaderPlugIn extends GenericNetCdfReaderPlugIn { | ||
|
||
// Set to "true" to output debugging information. | ||
// Don't forget to setback to "false" in production code! | ||
// | ||
private static final boolean DEBUG = false; | ||
|
||
private static final String DEFAULT_FILE_EXTENSION = ".nc"; | ||
|
||
public static final String READER_DESCRIPTION = "PACE OCIS L1C Products"; | ||
public static final String FORMAT_NAME = "PACE-L1C"; | ||
|
||
|
||
/** | ||
* Checks whether the given object is an acceptable input for this product reader and if so, the method checks if it | ||
* is capable of decoding the input's content. | ||
*/ | ||
@Override | ||
public DecodeQualification getDecodeQualification(Object input) { | ||
final File file = SeadasProductReader.getInputFile(input); | ||
if (file == null) { | ||
return DecodeQualification.UNABLE; | ||
} | ||
if (!file.exists()) { | ||
if (DEBUG) { | ||
System.out.println("# File not found: " + file); | ||
} | ||
return DecodeQualification.UNABLE; | ||
} | ||
if (!file.isFile()) { | ||
if (DEBUG) { | ||
System.out.println("# Not a file: " + file); | ||
} | ||
return DecodeQualification.UNABLE; | ||
} | ||
NetcdfFile ncfile = null; | ||
H5iosp.setDebugFlags(new DebugFlagsImpl("HdfEos/turnOff")); | ||
|
||
try { | ||
ncfile = NetcdfFileOpener.open(file.getPath()); | ||
if (ncfile != null) { | ||
Attribute scene_title = ncfile.findGlobalAttributeIgnoreCase("Title"); | ||
|
||
if (scene_title != null) { | ||
if (scene_title.toString().contains("PACE OCI Level-1C Data") | ||
|| scene_title.toString().contains("PACE SPEXone Level-1C Data") | ||
|| scene_title.toString().contains("HARP2 Level-1C Data")){ | ||
if (DEBUG) { | ||
System.out.println(file); | ||
} | ||
ncfile.close(); | ||
DebugFlags debugFlags = new DebugFlagsImpl("HdfEos/turnOff"); | ||
debugFlags.set("HdfEos/turnOff", false); | ||
H5iosp.setDebugFlags(debugFlags); | ||
return DecodeQualification.INTENDED; | ||
} else { | ||
if (DEBUG) { | ||
System.out.println("# Unrecognized scene title =[" + scene_title + "]: " + file); | ||
} | ||
} | ||
} else { | ||
if (DEBUG) { | ||
System.out.println("# Missing scene title attribute': " + file); | ||
} | ||
} | ||
} else { | ||
if (DEBUG) { | ||
System.out.println("# Can't open as NetCDF: " + file); | ||
} | ||
} | ||
} catch (Exception ignore) { | ||
if (DEBUG) { | ||
System.out.println("# I/O exception caught: " + file); | ||
} | ||
} finally { | ||
DebugFlags debugFlags = new DebugFlagsImpl("HdfEos/turnOff"); | ||
debugFlags.set("HdfEos/turnOff", false); | ||
H5iosp.setDebugFlags(debugFlags); | ||
if (ncfile != null) { | ||
try { | ||
ncfile.close(); | ||
} catch (IOException ignore) { | ||
} | ||
} | ||
} | ||
return DecodeQualification.UNABLE; | ||
} | ||
|
||
/** | ||
* Returns an array containing the classes that represent valid input types for this reader. | ||
* <p/> | ||
* <p> Intances of the classes returned in this array are valid objects for the <code>setInput</code> method of the | ||
* <code>ProductReader</code> interface (the method will not throw an <code>InvalidArgumentException</code> in this | ||
* case). | ||
* | ||
* @return an array containing valid input types, never <code>null</code> | ||
*/ | ||
@Override | ||
public Class[] getInputTypes() { | ||
return new Class[]{String.class, File.class}; | ||
} | ||
|
||
/** | ||
* Creates an instance of the actual product reader class. This method should never return <code>null</code>. | ||
* | ||
* @return a new reader instance, never <code>null</code> | ||
*/ | ||
@Override | ||
public ProductReader createReaderInstance() { | ||
return new SeadasProductReader(this); | ||
} | ||
|
||
@Override | ||
public SnapFileFilter getProductFileFilter() { | ||
String[] formatNames = getFormatNames(); | ||
String formatName = ""; | ||
if (formatNames.length > 0) { | ||
formatName = formatNames[0]; | ||
} | ||
return new SnapFileFilter(formatName, getDefaultFileExtensions(), getDescription(null)); | ||
} | ||
|
||
/** | ||
* Gets the default file extensions associated with each of the format names returned by the <code>{@link | ||
* #getFormatNames}</code> method. <p>The string array returned shall always have the same length as the array | ||
* returned by the <code>{@link #getFormatNames}</code> method. <p>The extensions returned in the string array shall | ||
* always include a leading colon ('.') character, e.g. <code>".hdf"</code> | ||
* | ||
* @return the default file extensions for this product I/O plug-in, never <code>null</code> | ||
*/ | ||
@Override | ||
public String[] getDefaultFileExtensions() { | ||
// todo: return regular expression to clean up the extensions. | ||
return new String[]{ | ||
DEFAULT_FILE_EXTENSION | ||
}; | ||
} | ||
|
||
/** | ||
* Gets a short description of this plug-in. If the given locale is set to <code>null</code> the default locale is | ||
* used. | ||
* <p/> | ||
* <p> In a GUI, the description returned could be used as tool-tip text. | ||
* | ||
* @param locale the local for the given decription string, if <code>null</code> the default locale is used | ||
* @return a textual description of this product reader/writer | ||
*/ | ||
@Override | ||
public String getDescription(Locale locale) { | ||
return READER_DESCRIPTION; | ||
} | ||
|
||
/** | ||
* Gets the names of the product formats handled by this product I/O plug-in. | ||
* | ||
* @return the names of the product formats handled by this product I/O plug-in, never <code>null</code> | ||
*/ | ||
@Override | ||
public String[] getFormatNames() { | ||
return new String[]{FORMAT_NAME}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change in the comment is not correct. In the end still a PixelGeoCoding is created.
By the way, the GeoCodingFactory should not be used anymore. It is better to use the ComponentGeoCoding. Probably we will soon change the implementation of GeoCodingFactory or maybe remove it at all. The new one is faster and more accurate.