Automate the code for data extraction

조회 수: 2 (최근 30일)
Debayan Mandal
Debayan Mandal 2022년 9월 26일
댓글: Mathieu NOE 2022년 10월 24일
I have multiple files of satellite data . Need to extract the data for a particular lat and lon. I have write the code for single data . Needs to run the code for all the files existing in the folder . The names of the files are :
g4.timeAvgMap.OMNO2d_003_ColumnAmountNO2TropCloudScreened.20190516-20220531.71E_19N_93E_47N
g4.timeAvgMap.OMNO2d_003_ColumnAmountNO2TropCloudScreened.20190401-20190415.70E_17N_76E_22N
The code i have written :
clear all;
close all;
clc;
filename='Delhi test.nc'
no2=ncread(filename, 'OMNO2d_003_ColumnAmountNO2TropCloudScreened');
longitude=ncread(filename,'lon');
latitude=ncread(filename,'lat');
[x1,y1]=meshgrid(longitude,latitude);
[r1,c1]=find(x1==77.3750);
[r2,c2]=find(y1==28.6250);
cc=no2(r1(1),c2(1))
Needs to modify the code so that this could be run in multiple files and data (which will be point data for each file ) can be stored by different variable names
Thanks in advance .

답변 (1개)

Mathieu NOE
Mathieu NOE 2022년 9월 26일
hello
you can try this :
folder= pwd; % put here folder where wav files are
C=dir(fullfile(folder,'*.nc')); %list all nc files in folder
nFiles=numel(C);
for i= 1:nFiles
% load new data
filename = C(i).name;
no2=ncread(filename, 'OMNO2d_003_ColumnAmountNO2TropCloudScreened');
longitude=ncread(filename,'lon');
latitude=ncread(filename,'lat');
[x1,y1]=meshgrid(longitude,latitude);
[r1,c1]=find(x1==77.3750);
[r2,c2]=find(y1==28.6250);
cc{i}=no2(r1(1),c2(1));
end

카테고리

Help CenterFile Exchange에서 CubeSat and Satellites에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by