I had hoped that the traceback exceptions would catch problems when reading the netCDF files, now I see that they did not. I have modified my code, updated the jar file linked above. This is basically what I have now. It still is not perfect, but hopefully raises an exception for failure to read the file or find the field.
def getGridFlatField(fileName,fieldLongName,sourceType = 'netcdf.grid'): """ Simplistic reading of netCDF file. Extra functionality can be added as needed.
inputFileName - full user path and name of grid file fieldLongName - found using ncdump or hover over field in Field Selector dataChoice - the flat field to return from grid dataType - netcdf.grid works for files loaded via Grid File(netCDF/GRIB/OpenDAP/GEMPAK) data handler
original code from McV forum: http://mcidas.ssec.wisc.edu/forums/viewtopic.php?f=31&t=894&hilit=managedDataSource&sid=1cb1e033255bb28ae0afc9124a69871a """ from os.path import exists
if exists(fileName): try: dataSource1 = makeDataSource(fileName, sourceType) except: raise Exception(sys.exec_info[0])
if not (dataSource1): errorMessage = "Read error loading file: " + fileName raise Exception(errorMessage) else: dataChoice1 = dataSource1.findDataChoice(fieldLongName) if not (dataChoice1): errorMessage = "Field not found: " + fieldLongName raise Exception(errorMessage) else: flatField1 = dataSource1.getData(fieldLongName) dataDescription1 = dataChoice1.getDescription() else: errorMessage = "File Not Found: " + fileName raise Exception(errorMessage)