
cd /Volumes/arguk/ASFS/asfs_coldtest_feb15to19/

x = rd_netcdf('ASFS_Test_ASFS_1min_1990_01_01_0000_1990_01_01_0000_2019_02_15_1627.nc');
tbeg = datenum([2019 2 15 16 0 0]);
tend = datenum([2019 2 19 10 30 0]);
dt   = 6/24;

dn = datenum([x.year x.month x.day x.hour x.min x.min.*0]);

clf;
plot(dn,x.PTemp_Avg,'linewidth',1); hold on;
plot(dn,x.vaisala_T_Avg,'linewidth',1);
plot(dn,x.efoy_Tint_Avg,'linewidth',1);
plot(dn,x.efoy_Tres_Avg,'linewidth',1);
plot(dn,x.efoy_Tst_Avg,'linewidth',1);
plot(dn,x.efoy_Twt_Avg,'linewidth',1);
legend('Logger Panel','Vaisala (room)','EFOY Tint','EFOY Tres','EFOY Tst','EFOY Twt','location','east');
xlabel('Time [DDHH]');
ylabel('Temperature [C]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on; hline(0);
set(gca,'xtick',tbeg:dt:tend,'ytick',-30:5:80); ylim([-30 75]);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 20]);      % 1 column, square
print -dpng temps.png


clf;
plot(dn,x.call_time_mainscan_Avg./1000,'.','linewidth',2); hold on;
xlabel('Time [DDHH]');
ylabel('Scan Time [sec]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 scantime.png


clf;
plot(dn,x.apogee_targ_T_Avg,'linewidth',1); hold on
plot(dn,x.apogee_body_T_Avg,'linewidth',1);
plot(dn,x.ir20_lwd_DegC_Avg,'linewidth',1);
plot(dn,x.ir20_lwu_DegC_Avg,'linewidth',1);
plot(dn,x.vaisala_T_Avg,'linewidth',1); hold on; 
plot(dn,T-273.15);
legend('IRT Targ','IRT Case','LWD Case','LWU Case','Vaisala (room)','location','northwest');
xlabel('Time [DDHH]');
ylabel('Temperature [C]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 room_temps.png

wvout = humidRS80(0.4096615,273.15-25,8,5,1000) % RH = 104% at -25 C
wvout = humidRS80(0.4096615,273.15-25+1.85,8,5,1000) % RH = 104% at -25 C



clf;
yyaxis left
plot(dn,x.vaisala_T_Avg,'linewidth',1);
ylabel('Room Temperature [C]');
yyaxis right
plot(dn,x.vaisala_RH_Avg,'linewidth',1);
ylabel('Room RH [%]');
xlabel('Time [DDHH]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 room_humidity.png


ind = find(DATA.GMDMET.t2m > -25 & DATA.GMDMET.t2m < -20);
histN(DATA.GMDMET.rh,0:105,'line'); hold on;
histN(DATA.GMDMET.rh(ind),0:105,'line');




clf;
plot(dn,x.efoy_Ust_Avg,'linewidth',1); hold on;
plot(dn,x.efoy_Uaus_Avg,'linewidth',1); hold on;
plot(dn,x.efoy_laus_Avg,'linewidth',1); hold on;
legend('Ust (stack voltage)','Uaus (voltage output)','Laus (current output)','location','south');
xlabel('Time [DDHH]');
ylabel('Current [Amps] & Voltage [V]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on; 
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 20]);      % 1 column, square
print -dpng efoyVA.png

% efoy cycles
d = [1 132 393 656 908 1160 1401 1640 1874 2106 2338 2449 2676 2904 3132 3360 3589 3815 4041 4130 4295 4520 4744 4970 5039 5263 5341];
cmap = lines;
plot(dn(d(2:end)),diff(d)./60,'^','markerfacecolor',cmap(1,:));
xlabel('Time [DDHH]');
ylabel('Cycles [hr]');
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 20 12]);      % 1 column, square
print -dpng -r300 efoycycles.png






clf;
plot(dn,x.sr50_dist_Avg,'.','linewidth',2); hold on;
xlabel('Time [DDHH]');
ylabel('SR-50 Distance [m]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 sr50.png




clf;
plot(dn,x.efoy_Pst_Avg,'linewidth',2); hold on;
plot(dn,x.efoy_Pper_Avg,'linewidth',2); 
xlabel('Time [DDHH]');
ylabel('EFOY Power');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
legend('Pst (Stack Power)','Pper (Periphery Power)','location','east');
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 efoypower.png



clf;
plot(dn,x.efoy_FuellSt_Avg); hold on;
xlabel('Time [DDHH]');
ylabel('EFOY Reservoir Fuel Level [%]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 efoyfuellev.png




clf;
plot(dn,x.efoy_MeOH_Avg); hold on;
xlabel('Time [DDHH]');
ylabel('EFOY MeOH Consumption [liters]');
title('ASFS INSTAAR Freezer Test, Feb 15-19');
grid on;
set(gca,'xtick',tbeg:dt:tend);
xlim([tbeg tend]);
datetick('x','ddhh','keepticks','keeplimits');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 28 16]);      % 1 column, square
print -dpng -r300 efoymeoh.png



                       PTemp_Avg: [5396×1 double]
                   batt_volt_Avg: [5396×1 double]
                 counts_main_Tot: [5396×1 double]
               counts_modbus_Tot: [5396×1 double]
                 counts_sdi1_Tot: [5396×1 double]
                 counts_sdi2_Tot: [5396×1 double]
      call_time_modbus_sr301_Avg: [5396×1 double]
      call_time_modbus_sr302_Avg: [5396×1 double]
    call_time_modbus_vaisala_Avg: [5396×1 double]
              call_time_sdi1_Avg: [5396×1 double]
              call_time_sdi2_Avg: [5396×1 double]
              call_time_efoy_Avg: [5396×1 double]
               efoy_Tint_Avg: [5396×1 double]
               sr30_swu_DegC_Avg: [5396×1 double]
               sr30_swu_DegC_Std: [5396×1 double]
                sr30_swu_Irr_Avg: [5396×1 double]
                sr30_swu_Irr_Std: [5396×1 double]
               sr30_swu_IrrC_Avg: [5396×1 double]
               sr30_swu_IrrC_Std: [5396×1 double]
               sr30_swd_DegC_Avg: [5396×1 double]
               sr30_swd_DegC_Std: [5396×1 double]
                sr30_swd_Irr_Avg: [5396×1 double]
                sr30_swd_Irr_Std: [5396×1 double]
               sr30_swd_IrrC_Avg: [5396×1 double]
               sr30_swd_IrrC_Std: [5396×1 double]
               apogee_body_T_Avg: [5396×1 double]
               apogee_body_T_Std: [5396×1 double]
               apogee_targ_T_Avg: [5396×1 double]
               apogee_targ_T_Std: [5396×1 double]
                   sr50_dist_Avg: [5396×1 double]
                   sr50_dist_Std: [5396×1 double]
                  vaisala_RH_Avg: [5396×1 double]
                  vaisala_RH_Std: [5396×1 double]
                   vaisala_T_Avg: [5396×1 double]
                   vaisala_T_Std: [5396×1 double]
                  vaisala_Td_Avg: [5396×1 double]
                  vaisala_Td_Std: [5396×1 double]
                   vaisala_P_Avg: [5396×1 double]
                   vaisala_P_Std: [5396×1 double]
                 ir20_lwu_mV_Avg: [5396×1 double]
                 ir20_lwu_mV_Std: [5396×1 double]
             ir20_lwu_Case_R_Avg: [5396×1 double]
             ir20_lwu_Case_R_Std: [5396×1 double]
               ir20_lwu_DegC_Avg: [5396×1 double]
               ir20_lwu_DegC_Std: [5396×1 double]
                 ir20_lwd_mV_Avg: [5396×1 double]
                 ir20_lwd_mV_Std: [5396×1 double]
             ir20_lwd_Case_R_Avg: [5396×1 double]
             ir20_lwd_Case_R_Std: [5396×1 double]
               ir20_lwd_DegC_Avg: [5396×1 double]
               ir20_lwd_DegC_Std: [5396×1 double]
                     fp_A_mV_Avg: [5396×1 double]
                     fp_A_mV_Std: [5396×1 double]
                     fp_B_mV_Avg: [5396×1 double]
                     fp_B_mV_Std: [5396×1 double]
            sr30_swu_fantach_Avg: [5396×1 double]
              sr30_swu_heatA_Avg: [5396×1 double]
            sr30_swd_fantach_Avg: [5396×1 double]
              sr30_swd_heatA_Avg: [5396×1 double]
                ir20_lwu_fan_Avg: [5396×1 double]
                ir20_lwd_fan_Avg: [5396×1 double]
                   efoy_MeOH_Avg: [5396×1 double]
                   efoy_Ubat_Avg: [5396×1 double]
                   efoy_laus_Avg: [5396×1 double]
                efoy_FuellSt_Avg: [5396×1 double]
                      efoy_Error: [5396×1 double]
                    efoy_Tst_Avg: [5396×1 double]
                   efoy_Tint_Avg: [5396×1 double]
                    efoy_Twt_Avg: [5396×1 double]
                  efoy_Tdcdc_Avg: [5396×1 double]
                   efoy_Tpcb_Avg: [5396×1 double]
                   efoy_Tres_Avg: [5396×1 double]
                   efoy_Taux_Avg: [5396×1 double]
                   efoy_Uaus_Avg: [5396×1 double]
                 efoy_Uklemm_Avg: [5396×1 double]
                   efoy_Uper_Avg: [5396×1 double]
                 efoy_UperIn_Avg: [5396×1 double]
                    efoy_Ust_Avg: [5396×1 double]
                   efoy_lper_Avg: [5396×1 double]
                    efoy_lst_Avg: [5396×1 double]
                    efoy_Pst_Avg: [5396×1 double]
                   efoy_Pper_Avg: [5396×1 double]


  
cd /Volumes/User/ccox/Documents/Projects/2019/MOSAiC_Meas/data_tests/Feb15-19_asfs_coldtest/ 
x = rd_netcdf('ASFS_Test_ASFS_1min_2019_02_15_1627.nc');
histN(diff(x.PTemp_Avg),-1:0.01:1,'line','linewidth',2);
xlim([-0.5 0.5]); vline(0);
set(gca,'xtick',-0.5:0.1:0.5); grid on;
xlabel('dT/dt [C/min]'); ylabel('[%]');
set(gca,'fontname','times','fontsize',12);
set(gcf,'PaperPositionMode','manual');
set(gcf,'PaperUnits','centimeters');
set(gcf,'PaperPosition',[0 0 16 16]);      % 1 column, square
print -dpng -r300 dTdt.png

  
  
  
                   