processing bs3 2010->2011 CMP using Paula's code =============================================== 2013/08/12 ran UnPacker-2.01.26.exe. Had to change from default firmware to firmware version 4.12, as prompted by the UnPacker software. Made two version, including a "human readable" one with dir name " _hr" from C*.MLHEX files: "instrumentModel": "RBR XRX-620", "instrumentFirmwareVersion": "6.60", "instrumentSerialNumber": "018025", copy mkdirs.src from ../bs3cmp2011to12, run it. - cp proc_paula from ../bs3cmp2011to12 to bs3_2010to11 profiler has 2044 profiles - 000 : 2043. Due to a programming error, these were successive up-down profiles (after the initial down profile 000) every 6 hours. The record ends on May 31. Pretty impressive, given the double-than-planned profile number. Consider whether to only include up- or down profiles in the final data ... which one is better? - edit cmp_asc2mat_fb3.m to set I/O, file range. Only do the first 50 to compare up/down profiles then run cmp_asc2mat_fb3.m make and run p_firstraw.m to look at up vs down. It is not obvious which one is better. I have a slight preference for the up-profiles, which may have just a bit less noise in T, C. Its not clear whether they combine better in S, sig from the quick checks I did with p_firstraw.m Good! They should not show a preference. - go ahead and select up profiles only for T,C,S,sig processing: -- run cmp_asc2mat_fb3.m for all files -- rename dir "raw" to "raw_updown", the copy all up profiles to -- new dir "raw" -- run program split_raw.m make one version for up- and one for down profiles (dirs raw_up and raw_down) plotting up their paths, the down profiles have fewer holes. Therefore, select the down profiles. Note: cmp_asc2mat_fb3 calls r_upackcmp3 to read the RBR format (new RBR format? unclear what we used before), which includes the subtraction of 10 dbar atmospheric pressure. next: e_cutstops2.m finds and excludes the "sitting" portion at the start/end of profiles. It generates plots to see if it works correctly. In preparation: - edit e_cutstops2.m to set profiles to work on (small number to start, then the whole she-bang); also pplot_y, the y-axis plot - check bs3_pgrid_input.m; update some position info, dirs, file names etc. - check nominal_ctd_calfile.mat. It contains: c_coefs 1x2 16 double p_coefs 1x2 16 double t_coefs 1x2 16 double tlag 1x1 8 double tlags_str 1x765 110152 struct the "_coefs" are all [1 0]. The lags are from earlier runs. Set tlag=1 and tlags_str=[] - for BS3 2010->11, used f_prfse2.m, which uses filtered pressure rather than averaged pressure to find traveling start/stops run e_cutstops2.m, files 002:2:2042 redo: 72 74 256 876 878 902 924 925 prf 1242 is no good: kept bouncing up and down during "down" prf without getting down far same for 1296 ran 1242 and 1296 through e_cutstops2 to selet only the first dive portion. next: determine best lag edit, then run: t_lags3p.m generates a bunch of .png files. As the plots scroll by, its quite clear that "1" is the winner. Early on, prfs were quite spiky in S and sig. I wonder about running the other batch, the up profiles, through the lags machine as well... Did that, and compared a number - not all - of the ups and downs in the early, spiky portion. If anything, my initial pick of the downs looks a bit better. So I stick with that. Look at a series of files starting with 0. If discernable, lags were always 1. After a while, skip in units of 200: look through a set of profiles until I've been convinced that there were no lags other than 1. Then skip to the next 200. Find no exceptions of lag=1. I make a file "lags_bs3_v0.txt" that contains "prf# lag#" when lags change, or an empty line if lots of prfs kept the same lag. This file would would normally be "filled" with fill_lags.m For BS3 2010->11, lag is always 1. So I simplify: df = fopen('tt.lags', 'w'); for ii=0:2:2042 fprintf(df, ' %4d %2d \n', ii, 1); end fclose(df); ! rename tt.lags lags.txt Convert lags.txt into a matlab structure using r_lagstxt.m. Note that lags.txt could have contained additional text etc., as it did for BS3_2009_2010. Save -append tlags_str to nominal_ctd_calfile.mat: save nominal_ctd_calfile tlags_str -append - run gridding: (in prep for spike editing) make sure input dir in bs3_pgrid_input is "rawcutstops", not just "raw" then run cmp_pgrid_mfile_after_rp after run of gridding: copy grd to grd_pre_e, because the raw editing program also grids and saves again if changes were made. also: copy "rawcutstops" to "rawcutstops_pre_e". Both of these "_pre_e" directories are used as the "_restore_dir"s in e_rawcmp7.m - next: e_rawcmp7.m; but as first done for BS3_2011to12, I don't do it interactively the first time around. Instead, make plots with p_rawcmp7.m. I will then run e_rawcmp7.m for files with short C spikes. look at 1254 1292 with e_rawcmp7; edit those. ---------------- after finishing raw edits, rerun gridding again: run cmp_pgrid_mfile_after_rp next: either cal or edit gridded data; Paula did cal, I like to do grid editing first. In either case: the next steps need the microcat: for 2010->11 BS3, we have bs3_201011_2137_cal.mat, which has had the the SeaBird lab call applied. Copy it from c:\projects\healy10_ta\mc_process\bs3_201011_mcd. to cmp_process\bs3_2010to11\mc ==> However, it still needs the field mc.datenumm: load it; >> mc.datenumm = mc.datenum; then save it again. next program on the list: MP_extract_bs.m it loads the grd/*.mat files for the CMP, and looks into the mc directory for any .mat files, which it interprets as mc/sc files. Saves output to grd/[inst]_MP_bot.mat error encountered for BS3_2010to11: calculating a CTD time from engineering data by cmp_pgrid_mfile_after_rp.m failed for a "profile" (1296) that consisted of short up/down segments. Calculating the minimum difference between eng and CTD pressure for index range assignment got the same indeces for start and end. Deviding by their difference led to devide by zero, and "-inf" in the gridded data (e.g., check in grd_rep_e/grd1296.mat). I inserted a fix to use the whole eng pressure range rather than from min_diff to CTD_p to max_diff to CTD_p. Ideally, the whole timing gets revised, though it would include finding out first WHY Paula used this odd relating between eng and CTD pressure. in cmp_pgrid_mfile_after_rp.m look for "if ncp == mcp" 2013/08/15 rerun cmp_pgrid_mfile_after_rp.m again with that fix in place 1296 was the only profile where ncp == mcp try again: MP_extract_bs.m ... okay this time. run identinv_EGC get statistical overview of CMP density inversions select "raw" - which actually loads grd files - as the only one available now program makes plots of statistics about inversions also makes {inst}_flag.mat needed for inversion_look.m, likely others as well. prepare to run inversion_look.m next. run MP_fakecal_egc.m, making cal/{inst}_cal.mat When asked, answer "n" to whether bs3 stopped profiling partway through, even if it did (see denmark strait ds2 notes) ====> don't forget!!! copy grd/{inst}_flag.mat from grd to cal. (could) run inversion_look.m (For bs3, as for ds4 and ds2 earlier, I skip running inversion_look.m ) prepare to run inversion_EGC run inversion_EGC.m - select "calibrated files", with only the fake cal being done. The other option would be "edited" , which is not the case yet. lots of edits for the first few days of deployment, in Sept. undo: - 126 (Oct 2, 18:00) undo all cadj, sadj fields; since no cal yet, can replace with c,s after edits are done: load ../edit/bs3_edt.mat datestr(MP.time(64,30)) % matches the above time MP.sadj(64,:) = MP.s(64,:); save ../edit/bs3_edt.mat MP run once more to double-check first: need to rerun identiv_EGC.m selecting "edited" input now: find 19 profiles with inversions. second: run inversion_EGC.m. Fix those. Autoimatically save output to edit/bs3_edt.mat ------------------------- prepare to adjust calibration based on comparison of deep CMP bin to microcat. 1) generate cal: Under Paula's scheme, this was done prior to editing. It made more sense to me to exclude bad data (e.g. when cond was obviously fouled on the way down) before making the comparison. I had already generated bs3_MP_bot by running MP_extract_bs.m earlier. Now I simply substitute the deep bin selected there: program adj_MP_bot.m After running adj_MP_bot, copied bs3_MP_bot_edt.mat to bs3_MP_bot.mat ' Check temperature: load ../grd/bs3_MP_bot plot(MPbot.time, MPbot.t) hold on plot(SC.time, SC.t, 'r') grid datetick('x', 2) title('BS3 compare CMP deep bin temperature (b) to MC (r)', 'fontsize', 12) orient portrait; print -dpng cmp_mc_deept find that aside from the events of warm/salty water intrusions (?), T is right on. run MP_cal_w_SEACAT_EGC.m (note, I am not running MP_cal_w_SEACAT_EGC_fb.m) Depth difference between MP and SC is 15.9763 Calculate gradient over what depth? 15 Gradient will be calculated over 10 points Do you want to change the depth range ("y" to change)? n run MP_applycal_EGC; Did bs3 stop profiling partway through deployment (y/n)? n Depth difference between MP and SC is 15.9763 updates ../cal/bs3_cal.mat: before: 08/15/2013 09:47 AM 2,570,120 bs3_cal.mat after: 08/16/2013 08:58 AM 2,887,362 bs3_cal.mat plot(MP.sadj(:,20) - MP.s(:,20)): find sadj is saltier by 0.14 psu (start) to 0.04 psu (end) However, looking more closely: the cal adjustment is based primarily on two large intrusions of warmer, saltier water early in the record. Paula estimates the vertical gradient over the bottom portion of the CMP record, which jibes with the CMP/mc difference. ===> after visual inspection of all plots: I decided that a zero correction, based on times without the intrusions, is more appropriate, and print out a set of figures to support the conclusion. (I offer to Bob/Eric to show and verify.) copy ../cal/bs3_cal_at_bot.mat to ../cal/bs3_cal_at_bot_bypaulaproc.mat load ../cal/bs3_cal_at_bot MP.cal = ones(size(MP.cal)); save ../cal/bs3_cal_at_bot MP copy ../cal/bs3_cal.mat to ../cal/bs3_cal_bypaulaproc.mat rerun MP_applycal_EGC plot(MP.sadj(:,20) - MP.s(:,20)) zero difference between the two make final files and plots 1) mkdir ../final don't use writeout_egc.m; instead make much simpler writeout_egc_ds3.m modified here as writeout_egc_bs3.m run writeout_egc_bs3.m takes cal/bs3_cal.m, generates final/bs3_edt.mat Note: check if transpose is needed (not here). We want final/[]_edt.mat to have MP(prof_no, bin_no): yes. 2) use f_rawprftimes_ds4.m, modified to f_rawprftimes_bs3.m, use the times from ascii file ds2_unpack/timetags.txt, which I parse with a code snipped from the Denmarkstrait routine proc_ini/r_cmpdata_dms2012.m: r_timetags_bs3.m run f_rawprftimes_bs3.m adds potential temp and density, inserts nans where there are gaps IMTRODUCED during editing into the initial profiler time series, as reflected in timetags.txt. ==> SO: <=== if timetags.txt, meaning the original profiler performance, has irregularities, they would still be in there!!! loads final/bs3_edt.mat, outputs final/bs3_edt_fb.mat make final plots: p_cmp_final.m =============================================================================== SUNA 2010->11 Sept 3, 2013 steps: - in c:\projects\healy10_ta\cmp_process\bs3_2010to11\suna, mkdir smatfiles % for .mat version of S*.TXT) mkdir smatfiles1 % for SUNA data matched with C pressure) - convert SUNA files from unpacked, not "human readable" S*.TXT files: run r_sunadata_1 note: only every other file is non-zero; => convert files 1:2:2043, where files is an index into the structure "D=dir('S0*.TXT') (need the "0" to exclude SNSRTIME.TXT) like for the previously processed 2011->12, only every other SUNA file had data (was non-zero size). In this case, though, because of the error in setting "paired profiles" to yes, each 6-hour cycle has both an up- and a down profile. So the SUNA is still getting 6-hour resolution. - derive SUNA pressure by matching SUNA dark readings with E stopgap lines. Note: this requires a parsed version of the C*.TXT files as typically generated in the proc_ini run onboard ship. currently, that (derive p) is done by t_match_se_1.m. Note: it sets the file name by specifying the file number, rather than the index into a D=dir structure. This makes a difference since our C,E,S files begin with number 0, not 1. - ran t_match_se_1.m for files 0:2:2042, or 1022 files. visually inspected the saved plots of CTD and SUNA pressure time series. Found several that did not come out right: when the profile got stuck, the time relation between CTD and SUNA looked very questionable. Decided to exclude these files: 864, 924, 1242, 1244, 1286, 1296, 1298, 1870 that leaves 1022-8=1014 profiles. - vertically bin the SUNA profiles: call_binsuna.m calls (a local copy of) depth_bin_cmp.m, set to match to match the 2-dbar bins of the final processed CMP, not the initial depth_bin_cmp.m settings used in proc_ini. Still, given the interrupted sampling (see fig of SUNA depth/time series) of the SUNA, I interpolate cross gaps within a SUNA profile. The final .mat file keeps the initial time series (SUNAraw), as well as the original binned and the interpolated binned data (structure SUNA with fields "_i" for interplated variables). - plot the data: p_cmpsuna_final.m; puts .png file into ../doc