Re: netCDF Java - Java Ncgen



Anh Tran wrote:
Institution: Data Center
Package Version: 2.2.12
Operating System: Windows
Hardware Information: Pentium 4
Inquiry: Dear John,
I try what you suggested by providing the full path for the files.  However it 
didn't work.  It give me the following errors:
java.io.FileNotFoundException:  (The system cannot find the path specified)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:222)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:115)
        at ucar.unidata.io.RandomAccessFile.<init>(RandomAccessFile.java:145)
        at ucar.nc2.NetcdfFile.open(NetcdfFile.java:213)
        at ucar.nc2.NetcdfFile.open(NetcdfFile.java:163)
        at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:291)
        at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:148)
        at ucar.nc2.ncml.NcMLReader.readNcML(NcMLReader.java:282)
        at ucar.nc2.ncml.NcMLReader.readNcML(NcMLReader.java:224)
        at ucar.nc2.ncml.NcMLReader.writeNcMLToFile(NcMLReader.java:1855)
        at dfo.Meds.argoNetcdf.CreateNetcdf.main(CreateNetcdf.java:26)

Can you help me? Thanks
Anh

The file cant be opened at that path name "D:\\java 
projects\\argo\\Netcdf\\example1.nc"

check the path name really exists
maybe you dont have write permission?
try using your current directory??

BTW, you can use "/" instead of "\\", even on windows.







------------------------------------------------------------------------

/*
 * Created on 17-Jan-06
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package dfo.Meds.argoNetcdf;

import ucar.ma2.*;
import ucar.nc2.*;
import ucar.nc2.ncml.*;
import ucar.nc2.dataset.*;
import ucar.nc2.FileWriter;
import java.io.*;

/**
 * @author Tran
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class CreateNetcdf {
    public static void main(String[] args){
        try {
            InputStream in = new FileInputStream("D:\\java 
projects\\argo\\Netcdf\\Example.ncml");
            NcMLReader.writeNcMLToFile(in,"D:\\java 
projects\\argo\\Netcdf\\example1.nc");
        }catch (IOException e){
            e.printStackTrace();
} }

}


------------------------------------------------------------------------

<?xml version='1.0' encoding='UTF-8'?>
<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'
    location='' >

  <dimension name='lat' length='3' />
  <dimension name='lon' length='4' />
  <dimension name='time' length='2' isUnlimited='true' />

  <attribute name='title' value='Example Data' />

  <variable name='rh' type='int' shape='time lat lon' >
    <attribute name='long_name' value='relative humidity' />
    <attribute name='units' value='percent' />
  </variable>
  <variable name='T' type='double' shape='time lat lon' >
    <attribute name='long_name' value='surface temperature' />
  </variable>
  <variable name='lat' type='float' shape='lat' >
    <attribute name='units' value='degree_north' />
  </variable>
  <variable name='lon' type='float' shape='lon' >
    <attribute name='units' value='degree_east' />
  </variable>
  <variable name='time' type='int' shape='time' >
    <attribute name='units' value='hours' />
  </variable>
</netcdf>


  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: