BrianOBlanton / adcirc_util

Public matlab codes for dealing with ADCIRC model output
MIT License
4 stars 5 forks source link

How to plot wind field in adcirc_util? #1

Closed jalal-90 closed 1 year ago

jalal-90 commented 1 year ago

In tutorial folder, there is a nice figure (please see the attachment) for wind field (wind and wind direction). How can I plot this figure using adcirc output?

interp2

jalal-90 commented 1 year ago

I am sorry for the inconvenience caused. I found the code. However, I am not getting the vector plot using the following code. I added the fort.14 and fort.74 files in the attachment.

clc;clear;close all fgs = grd_to_opnml('fort.14'); F74 = read_adcirc_fort('FileName','fort.74','Compact',1);

x =129:.25:141; y = 20:.25: 38;

[X,Y] = meshgrid(x,y);

% Then, find the elements that contain the points. The points outside of the grid will have NaNs for elements and % hence NaN's for the interp'ed value; they won't get plotted by MATLAB's plotting/drawing commands.

j = findelem(fgs,X,Y);

% NOTE: To interpolate a vector (u,v), define the complex uv=u+iv and interpolate the complex scalar uv.

uv = F74.uwind(:,45)+sqrt(-1)*F74.vwind(:,45); uvi= interp_scalar(fgs,uv,X(:),Y(:),j); uvi= reshape(uvi,size(X)); ui = real(uvi); vi = imag(uvi); vecplot(X,Y,ui,vi,'ScaleFac',1,'ScaleLabel','no scale','Color','r','LineWidth',2)

fort_14.zip

jalal-90 commented 1 year ago

Fort.74 https://www.dropbox.com/scl/fi/9lqtsyumy15ty9iy9ikbo/fort_74.zip?rlkey=z4awrqe469ragneqbz2ujacmy&dl=0

BrianOBlanton commented 1 year ago

Works for me, except that the file format is not compact. And clearly the vector mags need to be rescaled...

F74 = read_adcirc_fort('FileName','fort.74','Compact',0);

@.***

Cheers,

[signature_3166415283]

Brian O. Blanton, Ph.D. Director of Earth Data Sciences Oceanographer Renaissance Computing Institute University of North Carolina at Chapel Hill 100 Europa Drive Suite 540 Chapel Hill, NC, 27517

@.**@.> 919-445-9620 (O)

[signature_4084843005]

From: Md. Jalal Uddin @.> Date: Thursday, August 10, 2023 at 11:12 PM To: BrianOBlanton/adcirc_util @.> Cc: Subscribed @.***> Subject: Re: [BrianOBlanton/adcirc_util] How to plot wind field in adcirc_util? (Issue #1)

Fort.74 https://www.dropbox.com/scl/fi/9lqtsyumy15ty9iy9ikbo/fort_74.zip?rlkey=z4awrqe469ragneqbz2ujacmy&dl=0

— Reply to this email directly, view it on GitHubhttps://github.com/BrianOBlanton/adcirc_util/issues/1#issuecomment-1674161065, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AARBQQ3BUA56MH4JK5J4LMTXUWO4JANCNFSM6AAAAAA3AXW44Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jalal-90 commented 1 year ago

Thank you so much, sir. Now, I am having problem with vector arrow. I am waiting for your kind advice for the following condes.

pcolor(X,Y,test) hold on vecplot(fgs.x,fgs.y,F74.uwind(:,35),F74.vwind(:,35),'ScaleFac',1,'ScaleLabel','no scale','ScaleType','floating','Color','r','LineWidth',0.5) plotbnd(fgs,'Color','k','LineWidth',2) shading interp colorbar colormap(jet) xlabel('Longitue in degrees') ylabel('Latitude in degrees') title('Wind speed of Nanmadol','FontSize',16)

untitled

BrianOBlanton commented 1 year ago

It would be much more helpful if you actually told me the problem you are having.

Cheers,

[signature_3181861103]

Brian O. Blanton, Ph.D. Director of Earth Data Sciences Oceanographer Renaissance Computing Institute University of North Carolina at Chapel Hill 100 Europa Drive Suite 540 Chapel Hill, NC, 27517

@.**@.> 919-445-9620 (O)

[signature_383220208]

From: Md. Jalal Uddin @.> Date: Sunday, August 13, 2023 at 4:52 AM To: BrianOBlanton/adcirc_util @.> Cc: Blanton, Brian @.>, Comment @.> Subject: Re: [BrianOBlanton/adcirc_util] How to plot wind field in adcirc_util? (Issue #1)

Thank you so much, sir. Now, I am having problem with vector arrow. I am waiting for your kind advice for the following condes.

pcolor(X,Y,test) hold on vecplot(fgs.x,fgs.y,F74.uwind(:,35),F74.vwind(:,35),'ScaleFac',1,'ScaleLabel','no scale','ScaleType','floating','Color','r','LineWidth',0.5) plotbnd(fgs,'Color','k','LineWidth',2) shading interp colorbar colormap(jet) xlabel('Longitue in degrees') ylabel('Latitude in degrees') title('Wind speed of Nanmadol','FontSize',16)

[Image removed by sender. untitled]https://user-images.githubusercontent.com/139944952/260291954-f7d4f5ac-7094-49eb-a5a4-296c610fd82f.png

— Reply to this email directly, view it on GitHubhttps://github.com/BrianOBlanton/adcirc_util/issues/1#issuecomment-1676285992, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AARBQQ65Z5IQGIGQGZ7QWRLXVCIUDANCNFSM6AAAAAA3AXW44Q. You are receiving this because you commented.Message ID: @.***>

jalal-90 commented 1 year ago

Problem in the vecplot (in the above figure, the vectors are not placing right way). The vectors' position look abnormal.

BrianOBlanton commented 1 year ago

The vectors are drawn with the tail at the ADCIRC grid node locations. I don’t see anything wrong with that plot. Except that the pressure “pcolor” is clearly not at the same time as the velocity field.

Cheers,

[signature_735906082]

Brian O. Blanton, Ph.D. Director of Earth Data Sciences Oceanographer Renaissance Computing Institute University of North Carolina at Chapel Hill 100 Europa Drive Suite 540 Chapel Hill, NC, 27517

@.**@.> 919-445-9620 (O)

[signature_1908107774]

From: Md. Jalal Uddin @.> Date: Tuesday, August 15, 2023 at 8:55 PM To: BrianOBlanton/adcirc_util @.> Cc: Blanton, Brian @.>, Comment @.> Subject: Re: [BrianOBlanton/adcirc_util] How to plot wind field in adcirc_util? (Issue #1)

Problem in the vecplot (in the above figure, the vectors are not placing right way). The vectors' position look abnormal.

— Reply to this email directly, view it on GitHubhttps://github.com/BrianOBlanton/adcirc_util/issues/1#issuecomment-1679814573, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AARBQQYHDK42MQMSE3WINHTXVQK7TANCNFSM6AAAAAA3AXW44Q. You are receiving this because you commented.Message ID: @.***>