Data is not valid NDGRID format
7 次查看(过去 30 天)
显示 更早的评论
Hi Matlab Community,
I'm a new user of Matlab program. I got the error when I used the griddedInterpolant function to interpolate the data, this error is displayed in the below.
In addition, I also attach my controlling script in this post.
Please help me to resolve this problem!
Any suggestions will be appreciated.
Thanks all,
Bests,
Manh,
Error using griddedInterpolant
Data is not valid NDGRID format
Error in
FCr = griddedInterpolant(daplon,fliplr(daplat),fliplr(hs),method);
10 个评论
Manh Nguyen
2021-6-3
Hi KSSV,
Thank you for your answer.
I had modified a little bit in my sample.m file which is included in my zip file.
Thank you for your help.
Manh Nguyen
2021-6-3
编辑:Manh Nguyen
2021-6-4
I can not upload the nctoolbox zip file to this post because the size is larger than the maximum permission.
Thank you very much!
Scott MacKenzie
2021-6-4
It would be better if you post a small subset of your data -- enough to demonstrate, via code you also post, the issue you are trying to resolve.
Manh Nguyen
2021-6-4
Hi Mr. Scott MacKenzie,
Thank you for your recommendation.
I have posted all of my metarial in the firtst post which has my controlling script, one Matlab's function, one Grid needed to define the specpts and the data is downloaded in the through the URL.
Thank you for your enthusiastic help.
I'm really appreciated that!
Thank you again.
Scott MacKenzie
2021-6-4
Please re-read my comment. Posting "all your material" burdens anyone trying to help you with downloading, unzipping, importing multiple files, etc. I suggest you figure out a way to distill the issue down to something more manageable. It's usually best just to post a single spreadsheet or text data file and some code that accesses that data and demonstrates the issue you are trying to resolve.
Manh Nguyen
2021-6-4
Hi Mr. Scott MacKenzie,
I've changed my script into one file which is attached in this post. And the error in my case is displayed like that:
>> run sample.m
xl =
80.3980
xr =
155.4010
yb =
-11.7401
yt =
33.5703
getting hs tp and dp for 20200601.0000
Error using griddedInterpolant
Data is not valid NDGRID format.
Error in sample (line 50)
FCr = griddedInterpolant(daplon,fliplr(daplat),fliplr(hs),method);
Error in run (line 86)
evalin('caller', [script ';']);
Can you kindly help me to resolve this problem?
Thank you very much!
采纳的回答
Walter Roberson
2021-6-4
If
FCr = griddedInterpolant(daplon,fliplr(daplat),fliplr(hs),method);
gives you that problem, then the first thing to try is
FCr = griddedInterpolant(daplon.',fliplr(daplat).',fliplr(hs).',method);
16 个评论
Manh Nguyen
2021-6-4
Hi Walter Roberson,
I've tried using your modified command, but it still failed.
Error using griddedInterpolant
Data is not valid NDGRID format.
Error in sample (line 50)
FCr = griddedInterpolant(daplon.',fliplr(daplat).',fliplr(hs).',method);
Walter Roberson
2021-6-4
There were a couple of problems with the code.
The way that the code forms the grids of latitude and longitude were incorrect. That was causing the error message you were seeing about ndgrid.
But after I corrected that, I started getting error messages such as
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of 'open' function - 'Malformed or inaccessible DAP DDS (NC_EDDS)'. If the data source was an OPeNDAP URL, see the OPeNDAP
Troubleshooting section in the Users Guide.
At first it looked like the problem was occuring at the 8th time, but when I tried to investigate with debugging, the problem would go away for that time, and show up for a different time. I added in test code to retry upon failure, but that code turned out not to be enough.
At some point I realized that the difference between the program trying and me succeeding every time I tried to debug the problem, was a matter of timing: with me recalling the commands and thinking about the result, each of the ncread requests I was making was delayed relative to successive automatic tries.
I tried putting in a 2 second delay between tries, but that turned out not to be enough. I currently have it executing with a 10 second delay between tries, and that is working so far.
I suspect that the remote server is rate-limiting attempts to fetch data.
The proper correction is not to put in a delay between reads, like I did. The proper correction is to read the data for all of the time periods at the same time. It looks to me as if the processing for the time periods could be vectorized, but even if not, it should be easy to read all the data at the same time but then process one time period.
If my modified program succeeds with the 10 second delay, then I will post that version of the code, in order to permit you to get somewhere... but really it needs to be rewritten, which is something I expect would make the code much faster than my version that has the 10 second delay (with 129 time periods, 10 second delay requires over 20 minutes to read the data. I think the program could be much faster than that if it were rewritten.)
Manh Nguyen
2021-6-5
Hi Walter Roberson,
Thank very much for your enthusiactic help.
I'm really appreciated the time you spent on debuging my code.
Can you upload the modified code to me in order to examine the issue in my code?
By the way, I also attach the origional code which I think it will be useful for you to debug my code.
Thank you again.
Walter Roberson
2021-6-5
In your Sample.m the line
bdry_com(specpts)
was not able to execute because there is no function bdry_com provided with your code.
Adjusted code using the 10 second pause is attached. It does not fix the bdry_com problem as I do not know what that code is intended to do.
I recommend that the code be rewritten to read all of the time periods at the same time, and then process the resulting data. That would be much more efficient, and would solve the problem of the remote system refusing access because you access too often too soon.
Manh Nguyen
2021-6-5
编辑:Manh Nguyen
2021-6-5
Hi Roberson,
Thank you for your code, I will try that.
I attach the bdry_com.m program in this post.
Please try using it in your modified code.
Walter Roberson
2021-6-5
I suggest you experiment with reducing the pause(10) to pause(4): you can always increase it again if you need to. The code displays a warning message when it retries, so you will be able to see if retries are needed and if they help.
Manh Nguyen
2021-6-6
Hi Roberson,
Thank you very much for your help.
I've used your code and I got the report about the date of my data in 2020 but the data downloaded was in 2021:
>> run Sample.m
NCTOOLBOX added to Matlab path
url =
'http://nomads.ncep.noaa.gov:80/dods/wave/gfswave/20210601/gfswave.global.0p25_00z'
We are adding 0 to the roms longitude - line 34 ww3gb_2TPAR.m
getting hs tp and dp for 20200601.0000
getting hs tp and dp for 20200601.0300
Did you get the similar problem?
Walter Roberson
2021-6-6
Yes. The code was not interpreting the times correctly. The nc file was using days since 1-1-1 but the code was using datestr() to interpret them, and datestr() is relative to "year" 0 not year 1.
Edit the readww3_2TPAR2.m file, and in the line after assigning to time, add the line
time = time + 365; %base is 1-1-1 not 0-0-0 like datestr
The problem should not have affected the calculations, but it would have affected the display of the date.
Manh Nguyen
2021-6-6
Hi Roberson,
Thank you so much for your explanation. The problem is solved.
However, do you get the error related to the bdry_com program?
Error in Sample (line 51)
bdry_com(specpts) %script writes out file Bound_spec_command to working directory
Error in run (line 86)
evalin('caller', [script ';'])
It can not write out the Bound_spec_command file.
Walter Roberson
2021-6-6
I did not try yet. I have been working on someone else's code and that requires running code for multiple hours.
Walter Roberson
2021-6-6
Could you remind us which MATLAB version you are using? In places the code reads as if it was designed 20 years ago, but the bdry_com uses a feature from r2017a.
Manh Nguyen
2021-6-7
Hi Roberson,
Currently, I'm working with Matlab 2019b. So, does it affect the running code?
If yes, I hope that you can help me to resolve this issue.
I'm really appreciated your enthusiastic help.
Thank you very much!
Walter Roberson
2021-6-8
By the way, it looks like the server only keeps 7 days worth of data, so to keep working on this I had to select a different date.
Walter Roberson
2021-6-8
Adjusted versions of the files are attached.
Note the new function, read_with_retry . That is called by readww3_2TPAR2 in order to read each different variable more reliably.
This code has not been rewritten to try to read multipe timepoints at the same time. The guiding principle was "get it to work first!"
Manh Nguyen
2021-6-9
Hi Roberson,
Thank you very much for your help.
I've downloaded and run your modified scripts and they can run successfully.
I'd like to say that I'm really appreciate your help.
Thank you again.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
