netCDF Library not worling

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 ?

Welcome @tomtm! I just managed to install the latest release with Processing 3.5.4 on macOS Catalina by following the guide for manually installing contributed libraries.

What OS are you using?

Hi,
I‘m happy to hear from you :slight_smile:
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

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

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

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.

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

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 :slight_smile:

Best Regards
Tom

1 Like

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

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

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

/**
 * 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;
}

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