HOW TO READ, SAVE TXT, AND PLOT NC FILES?

2 visualizaciones (últimos 30 días)
della tan
della tan el 14 de Nov. de 2018
Respondida: KSSV el 15 de Nov. de 2018
I have 200 nc files. I need to read the data and save in txt but in another folder. After that my teacher want me to plot the data. What should I do? Im new in matlab. Please help. Here's the link https://drive.google.com/open?id=1JmPbtePjIYpz7_pEN7uScJYBXWfmXq8h
Thank you
  3 comentarios
della tan
della tan el 14 de Nov. de 2018
The reason why I didnt attach in this forum cs the file is too large is about 500 MB. Thats why i upload in gdrive. NC file is an altimetry satellite data format. And what I use in here is Jason-3 satellite which contain lat, lon, sla, etc but i dont know the spesific yet cause I cant read it.
dir_in='C:\Users\USER\Downloads\SEMESTER 7\ALTIMETRI\LAB1';
dir_out='C:\Users\USER\Downloads\SEMESTER 7\ALTIMETRI\LAB1';
file= dir(sprintf('%JA3%', dir_in));
just that.
Walter Roberson
Walter Roberson el 15 de Nov. de 2018
Editada: Walter Roberson el 15 de Nov. de 2018
The first of the files I peaked at had 177 variables stored in it
time meas_ind time_20hz lat lon lon_20hz lat_20hz surface_type alt_echo_type rad_surf_type rad_distance_to_land qual_alt_1hz_range_ku qual_alt_1hz_range_ku_mle3 qual_alt_1hz_range_c qual_alt_1hz_swh_ku qual_alt_1hz_swh_ku_mle3 qual_alt_1hz_swh_c qual_alt_1hz_sig0_ku qual_alt_1hz_sig0_ku_mle3 qual_alt_1hz_sig0_c qual_alt_1hz_off_nadir_angle_wf_ku qual_inst_corr_1hz_range_ku qual_inst_corr_1hz_range_ku_mle3 qual_inst_corr_1hz_range_c qual_inst_corr_1hz_swh_ku qual_inst_corr_1hz_swh_ku_mle3 qual_inst_corr_1hz_swh_c qual_inst_corr_1hz_sig0_ku qual_inst_corr_1hz_sig0_ku_mle3 qual_inst_corr_1hz_sig0_c qual_rad_1hz_tb187 qual_rad_1hz_tb238 qual_rad_1hz_tb340 rad_averaging_flag rad_land_frac_187 rad_land_frac_238 rad_land_frac_340 alt_state_flag_oper alt_state_flag_c_band alt_state_flag_band_seq alt_state_flag_ku_band_status alt_state_flag_c_band_status alt_state_flag_acq_mode_20hz alt_state_flag_track_trans_20hz rad_state_flag_oper orb_state_flag_diode orb_state_flag_rest ecmwf_meteo_map_avail rain_flag rad_rain_flag ice_flag rad_sea_ice_flag interp_flag_tb interp_flag_mean_sea_surface interp_flag_mdt interp_flag_ocean_tide_sol1 interp_flag_ocean_tide_sol2 interp_flag_meteo alt alt_20hz orb_alt_rate range_ku range_20hz_ku range_c range_20hz_c range_used_20hz_ku range_used_20hz_c range_rms_ku range_rms_c range_numval_ku range_numval_c range_ku_mle3 range_20hz_ku_mle3 range_used_20hz_ku_mle3 range_rms_ku_mle3 range_numval_ku_mle3 number_of_iterations_ku number_of_iterations_ku_mle3 number_of_iterations_c net_instr_corr_range_ku net_instr_corr_range_ku_mle3 net_instr_corr_range_c model_dry_tropo_corr model_wet_tropo_corr rad_wet_tropo_corr iono_corr_alt_ku iono_corr_alt_ku_mle3 iono_corr_gim_ku sea_state_bias_ku sea_state_bias_ku_mle3 sea_state_bias_c sea_state_bias_c_mle3 swh_ku swh_20hz_ku swh_c swh_20hz_c swh_used_20hz_ku swh_used_20hz_c swh_rms_ku swh_rms_c swh_numval_ku swh_numval_c swh_ku_mle3 swh_20hz_ku_mle3 swh_used_20hz_ku_mle3 swh_rms_ku_mle3 swh_numval_ku_mle3 net_instr_corr_swh_ku net_instr_corr_swh_ku_mle3 net_instr_corr_swh_c sig0_ku sig0_20hz_ku sig0_c sig0_20hz_c sig0_used_20hz_ku sig0_used_20hz_c sig0_rms_ku sig0_rms_c sig0_numval_ku sig0_numval_c sig0_ku_mle3 sig0_20hz_ku_mle3 sig0_used_20hz_ku_mle3 sig0_rms_ku_mle3 sig0_numval_ku_mle3 agc_ku agc_c agc_rms_ku agc_rms_c agc_numval_ku agc_numval_c net_instr_corr_sig0_ku net_instr_corr_sig0_ku_mle3 net_instr_corr_sig0_c atmos_corr_sig0_ku atmos_corr_sig0_c off_nadir_angle_wf_ku off_nadir_angle_wf_20hz_ku tb_187 tb_238 tb_340 tb_187_smoothed tb_238_smoothed tb_340_smoothed mean_sea_surface mean_topography geoid bathymetry inv_bar_corr hf_fluctuations_corr ocean_tide_sol1 ocean_tide_sol2 ocean_tide_equil ocean_tide_non_equil load_tide_sol1 load_tide_sol2 solid_earth_tide pole_tide wind_speed_model_u wind_speed_model_v wind_speed_alt wind_speed_alt_mle3 wind_speed_rad rad_water_vapor rad_liquid_water ice_range_20hz_ku ice_range_20hz_c ice_sig0_20hz_ku ice_sig0_20hz_c ice_qual_flag_20hz_ku mqe_20hz_ku mqe_20hz_ku_mle3 mqe_20hz_c peakiness_20hz_ku peakiness_20hz_c ssha ssha_mle3
You can examine the files using ncinfo, and you can read from them using ncread().
Beware though that the standard for .nc files is that the arrangement in memory is that adjacent pieces of information go across the rows, instead of down the columns like MATLAB uses. You need to be careful with how you index the variables, and you might find it easiest to transpose the data.

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 15 de Nov. de 2018
YOu may proceed like this. I am plotting ssha in the below code.
ncfiles = dir('*.nc') ;
N = length(ncfiles) ;
% loop for each file
figure
hold on
for i = 1:N
ncfile = ncfiles(i).name ;
lat = ncread(ncfile,'lat') ;
lon = ncread(ncfile,'lon') ;
ssha = ncread(ncfile,'ssha') ;
scatter(lon,lat,1,ssha,'filled')
end
You have to olny know about two to three functons to read ncfiles. ncinfo, ncdisp and ncread. With these three function you can achieve all waht you want.
Don't write the data into text file, it is waste of effort and memory. netCDF format is the best format available for storing the data of your kind. As you have not specified what exactly plot you wanted, I have demonstarted the plot of ssha. You can more or less extend the same to any other.

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by