DOI-USGS / COAWST

COAWST modeling system git repository
Other
108 stars 51 forks source link

Error to create the ww3partition_2TPAR #30

Closed Ntmanh18196 closed 3 years ago

Ntmanh18196 commented 3 years ago

Hi John, I have a problem which related to create the ww3partition_2TPAR data by using the ww3_swan_input.m program. I can run this program successfully with the data before 2018, however I got this error immediately when using the date of 2018. The error is displayed in the below: Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier. Error in fgetl (line 32) [tline,lt] = fgets(fid); Error in ww3partition_2TPAR (line 22) tline = fgetl(fid); Error in ww3_swan_input (line 76) ww3partition_2TPAR(partfile,specpts,yearww3,mmww3)

My program is attached in the below. Please help me to fix this problem. Thank you very much! ww3_swan_input.m.txt

jcwarner-usgs commented 3 years ago

let me work on this in the next few days.

Ntmanh18196 commented 3 years ago

Hi John, Can you kindly help me to resolve this error? Thank you in advance.

jcwarner-usgs commented 3 years ago

I am working on this but it is down the list. Suggest you try to run SWAN without TPAR BC's for now. When an update is available i will let you know.

Ntmanh18196 commented 3 years ago

Hi Joh, Thank you for your information. I hope the TPAR data will be available soon.

Ntmanh18196 commented 3 years ago

Hi John, Can you use the script ww3_swan_input.m to create TPAR files with grib data? Although I tried both grib and partition data, the program still failed with the data of 2017. I can run this script with the data of 2016.

jcwarner-usgs commented 3 years ago

ok. i just updated the method to get ww3 boundary data to drive swan with TPAR files. can you do an update and try to use the file: create_swanTpar_from_WW3 thanks, j

Ntmanh18196 commented 3 years ago

Hi John, I find out that the nww3 data on the site "ftp://polar.ncep.noaa.gov/pub/history/waves/nww3/" is available from 1997 to 2006 and the other on the website "https://nomads.ncep.noaa.gov/dods/wave/nww3" is available on 2021. Can I download the data with the time period which is between 2006 and 2021?

jcwarner-usgs commented 3 years ago

the ftp site is hindcast data up to 2006. Then nomads site is the current forecast (last 5 days). these are very different products. i encourage you to read the noaa sites and find the data that is best for you.

The m files that i just uploaded can get data from 2005-2019. I am not sure how to get ww3 data from 2019 to 2021.

Ntmanh18196 commented 3 years ago

Hi John, I got the error at line 10 of the readww3_2TPAR.m program: K>> lonww3_1d=double(ncread(hsurl,'lon')); zlon=length(lonww3_1d); Error using netcdflib The NetCDF library encountered an error during execution of 'open' function - 'file not found (-90)'.

Error in netcdf.open (line 67) [varargout{:}] = netcdflib ( 'open', filename, varargin{1} );

Error in internal.matlab.imagesci.nc/openToRead (line 1278) this.ncRootid = netcdf.open(this.Filename,'NOWRITE');

Error in internal.matlab.imagesci.nc (line 121) this.openToRead();

Error in ncread (line 61) ncObj = internal.matlab.imagesci.nc(ncFile); Please help me to resolve this issue. Thank you very much

jcwarner-usgs commented 3 years ago

did you change the dates to get the data? try this: hsurl = 'https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2012/10/glo_30m/multi_1.glo_30m.hs.201210.grb2'; lonww3_1d=double(ncread(hsurl,'lon'));

Ntmanh18196 commented 3 years ago

Hi John, Thank you for your reply, I've modified this program according to your suggestion, however, it still failed. The error is that: hsurl = 'https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2012/10/glo_30m/multi_1.glo_30m.hs.201709.grb2' getting ww3 lon lat and time Error using netcdflib The NetCDF library encountered an error during execution of 'open' function - 'file not found (-90)'. Error in netcdf.open (line 67) [varargout{:}] = netcdflib ( 'open', filename, varargin{1} );

Error in internal.matlab.imagesci.nc/openToRead (line 1278) this.ncRootid = netcdf.open(this.Filename,'NOWRITE');

Error in internal.matlab.imagesci.nc (line 121) this.openToRead();

Error in ncread (line 61) ncObj = internal.matlab.imagesci.nc(ncFile);

Error in readww3_2TPAR (line 12) lonww3_1d=double(ncread(hsurl,'lon'));

After changing, my program is that: function ww3gb_2TPAR(modelgrid,yearww3,mmww3,ww3_grid,specpts)

%set urls of the hsig, peak period, and dominant period

%eval(['hsurl=''https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/',yearww3,'/',mmww3,'/',ww3_grid,'/multi_1.',ww3_grid,'.hs.',yearww3,mmww3,'.grb2'';']) hsurl='https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2017/09/glo_30m/multi_1.glo_30m.hs.201709.grb2' eval(['tpurl=''https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/',yearww3,'/',mmww3,'/',ww3_grid,'/multi_1.',ww3_grid,'.tp.',yearww3,mmww3,'.grb2'';']) eval(['dpurl=''https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/',yearww3,'/',mmww3,'/',ww3_grid,'/multi_1.',ww3_grid,'.dp.',yearww3,mmww3,'.grb2'';']) % %first lets get the lon, lat, and time of the ww3 data disp(' getting ww3 lon lat and time') lonww3_1d=double(ncread(hsurl,'lon'));

In other case, I used the original script, it still didn't work. The error that I got is: Error using internal.matlab.imagesci.nc/read (line 613) START has incorrect number of elements (2). The variable has 3 dimensions. Error in ncread (line 66) vardata = ncObj.read(varName, varargin{:}); Error in readww3_2TPAR (line 53) hs=double(squeeze(ncread(hsurl,'Significant_height_of_combined_wind_waves_and_swell_surface',[ig0 jg0 tidx],[ig1-ig0+1 jg1-jg0+1 1])));

Please help me to resolve this issue. Many thanks.

jcwarner-usgs commented 3 years ago

please dont modify the code. just try this. copy these 2 lines into the matlab command and hit enter. does it work (do you get the longitudes)?

hsurl = 'https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2012/10/glo_30m/multi_1.glo_30m.hs.201210.grb2'; lonww3_1d=double(ncread(hsurl,'lon'))

Ntmanh18196 commented 3 years ago

Hi John, I copied 2 lines into the matlab command and it worked on my matlab. Do you find out the issue on my case?

jcwarner-usgs commented 3 years ago

what date are you getting data for? this line

"Error in readww3_2TPAR (line 53) hs=double(squeeze(ncread(hsurl,'Significant_height_of_combined_wind_waves_and_swell_surface',"

maybe the Varaible name is different in other years. i have seen that.

Ntmanh18196 commented 3 years ago

Hi John, I want the data in September, 2017. So according to your opinion, I should change the name of variables based on the description of each data, right?

jcwarner-usgs commented 3 years ago

the name of the url changed after 2017. do an svn update and try the new version of the code please.

Ntmanh18196 commented 3 years ago

Hi John, I ran the code but matlab reported that: Error in readww3_2TPAR (line 16) lonww3_1d=double(ncread(hsurl,'lon')); zlon=length(lonww3_1d);

Error in create_swanTpar_from_WW3 (line 46) readww3_2TPAR(modelgrid,yearww3,mmww3,ww3_grid,specpts) After that, I've tried entering 2 lines of the code and it worked.

hsurl = 'https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2017/09/gribs/multi_1.glo_30m.hs.201709.grb2'

hsurl ='https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncep/nww3/2017/09/gribs/multi_1.glo_30m.hs.201709.grb2'

lonww3_1d=double(ncread(hsurl,'lon')); zlon=length(lonww3_1d); latww3_1d=double(ncread(hsurl,'lat'));

jcwarner-usgs commented 3 years ago

ok. sorry for all this run around. i had to make the year be a number, and now i think it should work. can you do an update and try the method that is distributed?

-j

Ntmanh18196 commented 3 years ago

Hi John, Thank you for your enthusiastic help. I've tried your update code, but it failed at the line which you have told me about the error maybe come from the name of variables. So can you kindly give me the structure of these data?

create_swanTpar_from_WW3 NCTOOLBOX added to Matlab path working_dir ='E:\Matlab_udinit' getting ww3 lon lat and time We are adding 360 to the roms longitude - line 31 ww3gb_2TPAR.m getting hs tp and dp for 20170901.0000 Error using internal.matlab.imagesci.nc/read (line 613) START has incorrect number of elements (2). The variable has 3 dimensions. Error in ncread (line 66) vardata = ncObj.read(varName, varargin{:}); Error in readww3_2TPAR (line 56) hs=double(squeeze(ncread(hsurl,'Significant_height_of_combined_wind_waves_and_swell_surface',[ig0 jg0 tidx],[ig1-ig0+1 jg1-jg0+1 1]))); Error in create_swanTpar_from_WW3 (line 46) readww3_2TPAR(modelgrid,yearww3,mmww3,ww3_grid,specpts)

jcwarner-usgs commented 3 years ago

ok. it works for me yearww3='2017'; %input year of data yyyy mmww3='09'; %input month of data mm readww3_2TPAR(modelgrid,yearww3,mmww3,ww3_grid,specpts) getting ww3 lon lat and time We are adding 360 to the roms longitude - line 31 ww3gb_2TPAR.m getting hs tp and dp for 20170901.0000 getting hs tp and dp for 20170901.0300 ...

so it probably has something to do with your grid. what are the lon min and max of your grid?

Ntmanh18196 commented 3 years ago

Hi John, My lon_min is 91.6302871704102 and my lon_max is 166.390502929688. Does it affect to the data? I attach my ROM grid file, can you kindly help me find out the problem? ROMS_COAWST_grd1.zip

jcwarner-usgs commented 3 years ago

ok, hopefully last time. can you do an update and see if that works.

Ntmanh18196 commented 3 years ago

Hi John, I'm really appreciated about your enthusiastic help. Finally, it can work with my own case. One again, thank you so much! Have a nice and happy weekend!

jcwarner-usgs commented 3 years ago

glad it worked. have a good weekend.