Re: [netcdf-java] Converting NetcdfFile with multiple time steps to multiple NetcdfFiles with single time steps

Two ways you can do this:

1) If you can do something in NCO, it is probably much simpler to keep
doing it in NCO. From Java, you can call
  Process process = Runtime.getRuntime().exec(cmd);
to call an operating system process (but see the detailed examples on the
web for how to do this for your operating system), including calling NCO.

2) If I understand the problem, the only way I know of to do this with
netcdf-java, is to read the time and other data values and write the .nc
files with the individual time values and the data associated with each
time (and all the associated dimensions and attributes). That's the nature
of working with netcdf-java. (Perhaps someone else will chime in with a
simpler method.)

P.S. I don't know your reasons for using netcdf-java 4.2. I understand that
sometimes projects are, for now, locked into a certain version. But if you
can, I encourage you to switch to the latest version (4.6.8). Things are
done differently in recent versions of netcdf-java and various bugs have
been fixed. You'll probably have to switch to a modern version of Java
someday, so, if you can, you might as well switch now so you don't have to
rewrite this code later.




On Sun, Apr 2, 2017 at 6:19 AM, Alter, Ross E ERDC-RDE-CRREL-NH CIV <
Ross.E.Alter@xxxxxxxxxxxxx> wrote:

> Hi all,
>
> I'm using the Java Netcdf API (v4.2) to work with weather model output in
> Netcdf format.  However, I am trying to convert a  NetcdfFile with multiple
> time steps to a List of NetcdfFiles with single time steps, and I can't
> seem to find a direct way to accomplish this using the existing NetcdfFile
> methods without first reading a specific variable (which I would prefer not
> to do).  I'm aware of how to solve this using NCO, but I would like to
> solve this using Java since that is the language in which the software is
> written.  If you could please offer a suggestion on the most effective way
> to accomplish the above, I'd really appreciate it.
>
> Thanks a lot for your help!
>
> Ross
>
> _______________________________________________
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web.  Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
>
>
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>



-- 
Sincerely,

Bob Simons
IT Specialist
Environmental Research Division
NOAA Southwest Fisheries Science Center
99 Pacific St., Suite 255A      (New!)
Monterey, CA 93940               (New!)
Phone: (831)333-9878            (New!)
Fax:   (831)648-8440
Email: bob.simons@xxxxxxxx

The contents of this message are mine personally and
do not necessarily reflect any position of the
Government or the National Oceanic and Atmospheric Administration.
<>< <>< <>< <>< <>< <>< <>< <>< <><
  • 2017 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: