이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Data is not valid NDGRID format
조회 수: 6 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
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 (한국어)
