*/
public void writeGrid(String fileName, String gridName, int time,
int level, boolean greyScale,
LatLonRect pt) throws IOException {
double scaler;
GridDataset dataset = ucar.nc2.dt.grid.GridDataset.open(fileName);
GridDatatype grid = dataset.findGridDatatype(gridName);
GridCoordSystem gcs = grid.getCoordinateSystem();
ProjectionImpl proj = grid.getProjection();
if (grid == null) {
throw new IllegalArgumentException("No grid named " + gridName
+ " in fileName");
}
if ( !gcs.isRegularSpatial()) {
Attribute att = dataset.findGlobalAttributeIgnoreCase("datasetId");
if(att != null && att.getStringValue().contains("DMSP")){
writeSwathGrid(fileName, gridName,time,level, greyScale, pt);
return;
} else {
throw new IllegalArgumentException(