Message Boards Message Boards

Plot netcdf file?

Posted 6 years ago

Hi Mathematica experts. I am new to Mathematica so I have a question. How can I plot a netcdf file in Mathematica? Can you send me command for this netcdf file (SST)? test.nc

Thanks in advance. Samad

POSTED BY: abdossamad r
3 Replies

If you take a look at the dimensions of your data you will notice that it is wrapped into an additional layer (which could mean that it is kind of a 3D structure --- list of data):

data = Import["~/Downloads/test.nc",  {"Datasets",  "SST"}]; 
Dimensions[data]
(* ==> {1, 801, 1001} *)

So what you want to do here to plot the data, is getting rid of additional layer, which can be done as easy as:

data = First[data]; 
Dimensions[data]
(* ==> {801, 1001} *)

Now you can plot the data:

ArrayPlot[data]

enter image description here

Or you could plot it as it is:

ArrayPlot /@ data

All the rest, in the example from the documentation I refereed to, is matter of preference. For example here is how it looks when you reverse your data:

ArrayPlot[Reverse[data]]

enter image description here

Or, here is how the ColorFunction actually influences your plot:

ArrayPlot[Reverse[data],  ColorFunction -> "BlueGreenYellow"]

enter image description here

And so on, so force.

p.s. Please consider removing External Programs and Systems from your question's keywords, since it is not related to your question.

POSTED BY: Mikayel Egibyan
Posted 6 years ago

Thanks Do you have the experience of netcdf plot in mathematica? I acted as an example, but I did not succeed.

Import[ "D:/test.nc"] enter image description here

POSTED BY: abdossamad r

Alike example can be found in the documentation:

data = Import["ExampleData/precipitation.nc", {"Datasets", "ANOMALY"}];
ArrayPlot[Reverse@data, PlotRange -> {-2, 2.5}, ColorFunction -> "ThermometerColors", ImageSize -> Medium]

This is taken from NetCDF, which I strongly recommend you going through.

POSTED BY: Mikayel Egibyan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract