function Archive = read_sonde(path,period)
warning off
z = dir([path 'nsasonde*']);
%z = dir([path 'nsasondewnpnC1.b1.20180201.053000.cdf']);
Archive = [];
for i = 1:length(z)
    x = rd_netcdf([path z(i).name]);
    y = attribute_list([path z(i).name]);
    time = double(x.base_time)/60/60/24 + datenum([1970 1 1 0 0 0]) + double(x.time/60/60/24);
    base_time = double(x.base_time)/60/60/24 + datenum([1970 1 1 0 0 0]) + double(x.time(1)/60/60/24);
    % QC
    pres = x.pres;
    pres(x.qc_pres > 0) = NaN;
    tdry = x.tdry;
    tdry(x.qc_tdry > 0) = NaN;
    dp = x.dp;
    dp(x.qc_dp > 0) = NaN;
    wspd = x.wspd;
    wspd(x.qc_wspd > 0) = NaN;
    deg = x.deg;
    deg(x.qc_deg > 0) = NaN;
    rh = x.rh;
    rh(x.qc_rh > 0) = NaN;
    u_wind = x.u_wind;
    u_wind(x.qc_u_wind > 0) = NaN;
    v_wind = x.v_wind;
    v_wind(x.qc_v_wind > 0) = NaN;
    lat = x.lat;
    lon = x.lon;
    alt = x.alt;
    
    % accumulate
    Archive = [Archive; base_time*ones(length(time),1) time double(pres) double(tdry)  double(dp) double(wspd) double(deg) double(rh) double(u_wind) double(v_wind) double(lat) double(lon) double(alt)];
end

Archive(Archive(:,2) < datenum(period(1,:)) | Archive(:,2) > datenum(period(2,:)) + 1,:) = [];
clear mex


