[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GEMPAK #UGL-929049]: gem to netcdf
- Subject: [GEMPAK #UGL-929049]: gem to netcdf
- Date: Thu, 21 May 2009 16:27:07 -0600
Hi Akhilesh,
We have a Java API that will read in a GEMPAK grid file and output a netCDF
file using CF conventions.
It's the netCDF-Java library available at:
http://www.unidata.ucar.edu/software/netcdf-java
The gempak file reading is part of the netCDF-Java library in the
ucar.nc2.iosp.gempak package. The writing is in the ucar.nc2.dt.grid package.
I've attached a sample program that will read a gem file and write it out as
netCDF.
You may need to download the netcdfAll-4.0.jar from this link:
ftp://ftp.unidata.ucar.edu/pub/netcdf-java/v4.0/netcdfAll-4.0.jar
then run the program as:
java -Xmx512m -classpath netcdfAll-4.0.jar;. GempakToCF GEM_FILE.gem
NETCDF_FILE.nc
the netcdfAll jar file has all the libraries you need contained in it.
Michael
> Dear GemPak Users and support group,
> I was wondering if there is any tool/script available to convert the model
> forecasts format (from .gem to netcdf or binary format).
> I am new user and i just installed GemPak to Linux 64 bit (CentOS) machine.
> Looking forward to hear from the group.
> Best wishes and Regards
> Akhilesh
>
>
Ticket Details
===================
Ticket ID: UGL-929049
Department: Support GEMPAK
Priority: Normal
Status: Open
import ucar.nc2.dt.grid.*;
import java.util.List;
import java.util.ArrayList;
public class GempakToCF {
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.out.println("You must supply an input and output file name");
System.exit(1);
}
String input = args[0];
String output = args[1];
GridDataset gds = GridDataset.open(input);
List grids = gds.getGrids();
List names = new ArrayList(grids.size());
for (int i=0; i<grids.size(); i++) {
names.add(((GeoGrid) grids.get(i)).getName());
}
NetcdfCFWriter writer = new NetcdfCFWriter();
writer.makeFile(output, gds, names, null, null, false, 1, 1, 1);
}
}