# netCDF Library not worling

**URL:** <https://discourse.processing.org/t/netcdf-library-not-worling/29077>\
**Category:** Libraries\
**Created:** [April 3, 2021, 12:42am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077 "2021-04-03T00:42:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 3, 2021, 12:42am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/1 "2021-04-03T00:42:03Z")

</div>

Hi,  
I found this netCDF Library, but I am not able to get it to run, it always says, that the netcdf library isn‘t available. To check I trief to run the example files coming with this library.  
Could someone check, if the linrary is workinh in 3.5.4 ?

> **[nickmcintyre/processing-netcdf](https://github.com/nickmcintyre/processing-netcdf)**
>
> Simple access to scientific datasets with Processing

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 3, 2021, 1:37am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/2 "2021-04-03T01:37:22Z")

</div>

Welcome @tomtm! I just managed to install the [latest release](https://github.com/nickmcintyre/processing-netcdf/releases/download/v0.1.1/netcdf.zip) with Processing 3.5.4 on macOS Catalina by following the guide for [manually installing contributed libraries](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library).

What OS are you using?

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 3, 2021, 1:54am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/3 "2021-04-03T01:54:34Z")

</div>

Hi,  
I‘m happy to hear from you 🙂  
I‘m using Win 10 Pro.  
I installed your library to the libraried folder  
In the sketchbook folder, where other libs are stored.  
I can send you the exact pathes tomorrow, when I am in the office.  
Would be great if I could use your lib.

I send you more info tomorrow.

Best Tom

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 3, 2021, 2:10am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/4 "2021-04-03T02:10:35Z")

</div>

Sounds good – I’ll get a machine running Windows 10 so I can test that as well.

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 3, 2021, 1:09pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/5 "2021-04-03T13:09:01Z")

</div>

Hi,  
I copied the library to:

Task A)  
C:\Users\tom\Documents\Processing\libraries\netcdf  
if I start one of your example, the library won’t be found

Task B)  
if I rename the folder in your library from lib to library and the netcdfAll-5.3.3.jar to netcdfAll.jar  
the library is listed in the “import library” window in processing.  
if I run your example there is following message:

“No library found for netcdf  
Libraries must be installed in a folder named ‘libraries’ inside the sketchbook folder (see the Preferences window).  
The package “netcdf” does not exist. You might be missing a library.”

“The class PDataset” does not exist.

So I guess it’s a naming issue somewhere? Or what did I forget?

Thank you a lot  
Tom

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 3, 2021, 6:31pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/6 "2021-04-03T18:31:40Z")

</div>

Strange. I just managed to load an example on a machine running Windows 10. What is the full path to the netcdf library folder after you’ve extracted it? Here is an example of what you should see in File Explorer.

 ![netcdf-install-path](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/82d0b966667732323599242ed851a9b265c5ffee.png)

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 4, 2021, 10:05am UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/7 "2021-04-04T10:05:59Z")

</div>

Hi mcintyre  
now it works! I probably don’t know how to use GitHub 🙂  
I downloader your netcdf-master package instead of the versions in the tag section.  
With version 0.1.1. it works like a charme

> **[nickmcintyre/processing-netcdf](https://github.com/nickmcintyre/processing-netcdf/tags)**
>
> Simple access to scientific datasets with Processing

Sorry, I am more from the artistic background and I am new to coding.  
But thank you very much for your help and sorry for any circumstances.

Now I have to understand the cdf format 🙂

Best Regards  
Tom

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 4, 2021, 12:12pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/8 "2021-04-04T12:12:48Z")

</div>

Glad to hear it! Let me know how your work progresses – happy to help troubleshoot.

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 4, 2021, 7:55pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/9 "2021-04-04T19:55:25Z")

</div>

Thank you. Just one thing.  
The WRF Example works, the two other don’t, it says  
Inspecting ‘Temperature\_surface’ variable…  
NullPointerException  
NullPointerException

It this because of missing data online? just wondering

Greets Tom

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 4, 2021, 9:52pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/10 "2021-04-04T21:52:07Z")

</div>

Looks like it. Here is an example that pulls data from a different (lower resolution) data set.

```java
/**
 * THREDDS Example.
 *
 * Load weather data from the Unidata Test THREDDS Data Server, then
 * display surface wind velocity and temperature. Visualization gratefully
 * borrowed from p5.js. (CC BY-NC-SA)
 *
 * https://p5js.org/examples/hello-p5-weather.html
 */
import netcdf.*;

PDataset data;
PVector position;
PVector wind;
String temp, wspd;

void setup() {
  size(720, 200);
  
  data = new PDataset(this);
  String url = "https://thredds-jumbo.unidata.ucar.edu/thredds/dodsC/grib/NCEP/RAP/CONUS_13km";
  data.openFile(url);

  data.loadData("u-component_of_wind_height_above_ground", "0:1,0:1,0:0,0:1,0:1");
  data.loadData("v-component_of_wind_height_above_ground", "0:1,0:1,0:0,0:1,0:1");
  data.loadData("Temperature_height_above_ground", "0:1,0:1,0:0,0:1,0:1");
  
  float[][][][][] u = data.get5DFloatArray("u-component_of_wind_height_above_ground");
  float[][][][][] v = data.get5DFloatArray("v-component_of_wind_height_above_ground");
  float[][][][][] t = data.get5DFloatArray("Temperature_height_above_ground");
  
  position = new PVector(width/2, height/2);
  wind = new PVector(u[0][0][0][0][0], v[0][0][0][0][0]);
  temp = String.format("%.1f˚C", t[0][0][0][0][0] - 272.15);
  wspd = String.format("%.1f m/s", wind.mag());
  
  data.close();
}

void draw() {
  background(200);
  
  pushMatrix();
  // Display temperature and windspeed
  textSize(16);
  text(temp, 64, height - 32);
  text(wspd, 64, height - 16);
  
  translate(32, height - 32);
  // Rotate by the wind's angle
  rotate(wind.heading() + PI/2);
  noStroke();
  fill(255);
  ellipse(0, 0, 48, 48);

  stroke(45, 123, 182);
  strokeWeight(3);
  line(0, -16, 0, 16);

  noStroke();
  fill(45, 123, 182);
  triangle(0, -18, -6, -10, 6, -10);
  popMatrix();
  
  // Move in the wind's direction
  position.add(wind);
  
  stroke(0);
  fill(51);
  ellipse(position.x, position.y, 16, 16);

  if (position.x > width) position.x = 0;
  if (position.x < 0) position.x = width;
  if (position.y > height) position.y = 0;
  if (position.y < 0) position.y = height;
}

```

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 5, 2021, 9:40pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/11 "2021-04-05T21:40:48Z")

</div>

cool, thank you, this works, so I can learn from this example.  
Best Regards  
Tom

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 29, 2021, 3:31pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/12 "2021-04-29T15:31:45Z")

</div>

Hi mcintyre

I’m experimenting with some data.  
I realized, that I can’t access 1 dimensional array data using:

It says that variable lat is loaded but not casted in an 1d array.  
In NetCDF Viewer, I can see the data. [NetCDF Viewer is a windows software for vieweing NetCDF files (agrimetsoft.com)](https://agrimetsoft.com/NetCDF-Viewer)

float latData [] = data.get1DFloatArray(“lat”);  
Error: ClassCastException: [D cannot be cast to [F

2,3,4,5 dimensional Arrays are working.

Or is there another way to do?

Greets Tom

---

<div class="post-metadata">

**Author:** ![tomtm](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tomtm](https://discourse.processing.org/u/tomtm)\
**Post date:** [April 29, 2021, 3:45pm UTC](https://discourse.processing.org/t/netcdf-library-not-worling/29077/13 "2021-04-29T15:45:01Z")

</div>

hmmm, wait… with another sample file, I can access 1D Arrays.  
[https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b\_ncar\_ccsm3-example.nc](https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc)

I have to do some more research now, what’s the difference between my file and the example above.

update: I got it, it’s a double instead of float 🙂  
I didn’t knew about the “get1DDoubleArray”
