Creating a 3D variable from a 1D variable with NCO - netcdf

I have a 1D variable describing height in my NetCDF file. I'd like to create an 3D variable that is uniform on the X and Y axes from this column of data. Is there an easy way to do this in NCO?

If the 1-D axes are named x and y and z, then construct a 3D field containing z that is uniform over x and y with ncap2:
ncap2 -s 'z_3D[z,y,x]=z' in.nc out.nc
Pretty cool, huh?

Related

How to draw 3d vectors in gnuplot?

I want to draw several vectors in a 3D plot. The co-ordinates of the start and end point are columns in a data file. In 2D, I plot vectors by:
plot 'data.dat' u 1:2:($3-$1):($4-$2) with vectors
How can I do it in 3D?
Edit
I am trying to draw these vectors on top of a surface. When I try this:
set hidden3d
set xlabel "x"
set ylabel "y"
set zlabel "z"
set dgrid3d 10,10 qnorm 2
file = "surface.dat"
splot file u 1:2:3 with lines, file 1:2:3:($4-$1):($5-$2):($6-$3) with vectors
I get the surface, but not the vectors. (The vectors are out of the plane of the surface, like normals.)
Have you done any search at all? Have you checked the gnuplot homepage or gnuplot documentation?
From help vectors:
`The 2D vectors style draws a vector from (x,y) to (x+xdelta,y+ydelta). The 3D vectors style is similar, but requires six columns of basic data. In both cases, an additional input column (5th in 2D, 7th in 3D) may be used to provide variable (per-datapoint) color information. (see linecolor and rgbcolor variable). A small arrowhead is drawn at the end of each vector.
4 columns: x y xdelta ydelta
6 columns: x y z xdelta ydelta zdelta
... and further down...
Example:
plot 'file.dat' using 1:2:3:4 with vectors head filled lt 2
splot 'file.dat' using 1:2:3:(1):(1):(1) with vectors filled head lw 2
Hence, depending on your columns:
splot 'data.dat' u 1:2:3:($4-$1):($5-$2):($6-$3) with vectors

Colorplot in Julia with awkward data format

I have data in the form of a list of tuples (x,y,z) with no particular ordering on the (x,y) values. I want to make a color plot in the x-y plane where z is represented by a color, using the PyPlot function
pcolor
The issue is this function accepts data in the format arr_x,arr_y,image where arr_x and arr_y are 1D arrays and image is a 2d Array such that image[i,j] corresponds here to the z value for x=arr_x[i],y=arr_y[j].
Is there a simple way to do this (without constructing the 2D array image, which would be annoying).
Are you looking for scatter?
using Plots, Unzip # Unzip to go from list of tuples to tuple of lists
data = [(randn(), randn(), randn()) for _ in 1:200] # list of (x,y,z) tuples
x, y, z = unzip(data) # get vectors out of the tuple
scatter(x, y, zcolor=z)
will output

R - using heatmaply for a 2d histogram / density

I'm rather new to programming and the site so let me know if I screw up on this explanation.
I have a rather long series of x, y coordinates representing a character in 2d space. Let's say that space is 200 x 400. I want to represent the amount of time the character is in each x, y coordinate by means of a pretty chloropleth.
I want to use heatmaply for this because I think the output is pretty and I want my audience to be able to zoom in on the data. It isn't really meant to do density estimation (I think?) so I'm trying to work around it.
I suppose the way to do this is to fill a 200x400 dataframe with counts of the number of occurrences of each x, y coordinate in the data at each x, y coordinate in the frame. Essentially, to build a 2d map out of the data frame and impose the counts upon it
So, I suppose my questions are:
1). How do I get the count of each unique x, y coordinate in my set
2). How might I pass those counts easily to the matching x, y cell in my 200x400 dataframe full of zeroes?
This seems like it should be easy but I can't seem to figure it out! I'm a novice to r and can't see the shape of what I need to do.
You can use the table function to get your matrix of counts.
table(X,Y)
X and Y should be columns of coordinates.
Output based on some sample data

Data file format for 3d plots in Octave

I have file(s) containing N X values and M Y values. Also one containing Z at each value of (X,Y). So N rows and M columns.
I did this:
a=load('z.txt')
surf(a)
which plots Z ok but the axes are just the datapoint number. How do I get the axes to match the X and Y data?
This seems to do the trick:
x=load('x.txt')
y=load('y.txt')
z=load('z.txt')
surf(x,y,z)
Although there are probably more elegant ways.

Gnuplot: coloring area inside uncertainty

I have a bunch of 2D points, each point comes with an error in the x coordinate and in the y coordinate. I don't like how with xyerrorbars shows the points because these are measurement that will be more and more dense.
I'd like if these points could form a colored surface, like these kind of plots:
http://www-cdf.fnal.gov/physics/new/hdg/Results_files/results/hwwmenn_120224/figures/limit/cdf4g17july2011.gif
Do you know if there's there a striagth forward way in Gnuplot?
Thanks!
I will assume that your data file is in the following format:
x y sx sy
where sx and sy are the standard deviations in x and y. You can use the filledcurves option to plot:
plot 'data.dat' using 1:($2+2*$4):($2-2*$4) title '+/- 2 SD', \
'data.dat' using 1:($2+$4):($2-$4) title '+/- 1 SD', \
'data.dat' title 'data'
help filledcurves gives you a couple of examples.

Resources