Closed AsimUdel closed 3 months ago
Hi @AsimUdel
There shouldn't be any changes you need to make to the AMR-Wind input file itself. The sampling output files should be viewable in any environment that can load netcdf files, and if you can view them through the amr-wind-frontend GUI, then it ought to be possible to plot them in a jupyter notebook.
One thing that you can try is using a notebook like this one to visualize the sampling00000.nc
:
https://github.com/lawrenceccheung/ALCC_Frontier_WindFarm/blob/main/precursor/MedWS_LowTI/postprocessing/HubHeight_Viz.ipynb
This one might be a little more lightweight notebook, and doesn't require loading the full amr-wind-frontend library in order for it to work.
Let me know if you have any questions about how to use it, or if you run into any issues loading it.
Lawrence
Hi @lawrenceccheung Thank you so much, I have tried opening in Python using Jupyter notebook, I have come up with some error, Let me attach the file containing error, maybe I am doing something w error_while_opening_netcdf_file.txt rong. I would be grateful if you could guide me how to use https://github.com/lawrenceccheung/ALCC_Frontier_WindFarm/blob/main/precursor/MedWS_LowTI/postprocessing/HubHeight_Viz.ipynb this file.
Hi @AsimUdel,
In the part of your script where you calculate the horizontal velocity
>>> iplane=1
>>> Uh=np.sqrt(db['velocityx'][0][iplane,:,:]**2)
set iplane=0
. You only have one plane defined for xyplane
, so that's why this error message appears:
IndexError: index 1 is out of bounds for axis 0 with size 1
Note that you have both the xyplane
and yz
contained in sampling00000.nc
. By default, getPlaneXY()
will extract the first plane that it sees (xyplane
). To get the other plane, use the groupname
option:
db = ppsamplexr.getPlaneXR(amrdir+ncfile, iters, varnames, groupname='yz', verbose=0)
Lawrence
If you're using xarray
, you will often have to specify the group
variable when running xr.open_dataset
. Below I've attached a screenshot of some code where I ran 6 different spinup simulations (I was trying different roughness and surface flux heat values), and you can see how I open the netCDF data of each of those simulations and concatenate them. I end up with two Datasets in the end: one for the profile variables (pstats
) and one for the other variables.
@lawrenceccheung I have tried as you suggested, I have attached screenshot of the Jupyter notebook and output of sampling00000.nc by GUI (AMR-Wind-Frontend), I don't know how to access the variable using Jupyter notebook my planes input files are yz-2D ,yz-4D, yz_0D, yz_2D, yz_4D, yz_6D, yz_8D xy_hub xy_rotor_top xy_rotor_bottom Kindly suggest me how to see the list of variables and shape so that I can plot them.
hi @AsimUdel, in your case use
Uh = np.sqrt(db['velocityx'][2][iplane,:,:]**2)
In that last cell.
The dictionary that is returned by ppsamplexr.getPlaneXR()
has the following structure:
db[varkey][iterkey][planenum, i, j]
where:
varkey
corresponds to the variable name (in your case velocityx
)iterkey
corresponds to the time instance of the plane. In your case, you only extracted the slice corresponding iterkey
=2 because you specified iters=[2]
above.planenum
is the offset plane number of the sample plane. In all cases you will have planenum=0
present, and if in the input file you provide. If you used the offsets
specification in the input file, like in this example:
turbswA_.T0_swA.type = PlaneSampler
turbswA_.T0_swA.num_points = 601 45
turbswA_.T0_swA.origin = 730.0 2560.0 0.08400000000000318
turbswA_.T0_swA.axis1 = 3810.0 0.0 0.0
turbswA_.T0_swA.axis2 = 0.0 0.0 280.416
turbswA_.T0_swA.normal = -0.0 1.0 -0.0
turbswA_.T0_swA.offsets = 0.0 254.0 508.0
you can specify planenum
=1 or 2 as well.
i
and j
are the x and y indices of the plane that will be used to plot.Hope this helps.
Lawrence
@lawrenceccheung Thank you so much for comprehensive guide, right now I have plotted it.
If you're using
xarray
, you will often have to specify thegroup
variable when runningxr.open_dataset
. Below I've attached a screenshot of some code where I ran 6 different spinup simulations (I was trying different roughness and surface flux heat values), and you can see how I open the netCDF data of each of those simulations and concatenate them. I end up with two Datasets in the end: one for the profile variables (pstats
) and one for the other variables.
@rybchuk Thank you so much, I will definitely look into that as (there must be many output files), I will try and get back to you soon.
Hello, I am having trouble in reading the variables in my output file (.nc) (sampling00000.nc) file when I try to open in Python Jupyter notebook but I am able to read and see in AMR-Wind-Frontend (GUI), could someone please tell me what I should change in my input file so that I could see variables using Python or how to visualize the output file with some other tools? I am attaching my input file here in the attachment. Thank you AMR-Wind_input_file.txt