DirtySumfiles

Here are the MATLAB functions used to make sumfiles and nominals. Both functions need to be in the same directory to work. Dirty_SUMFILES_f.m is nested within Master_Sumfiles.m. Also, Master_Sumfiles.m is set up to put the sumfiles in the directory /Users/kdrozd/send/DS_DN_FILES/DIRTYSUMFILES and the nominals are set up to go to the directory /Users/kdrozd/send/DS_DN_FILES/DIRTYNOMINALS.

Also, Master_Sumfiles.m is currently set up for Polycam. This can be changed by editing line 72.

Master_Sumfiles.m

% Master_Sumfiles% Made by Kristofer Drozd% 09/10/15 updated 12/15/15% distance_sc vecter - row vector contraining sc distance to LMRK% BENNU2LMRK_mat - matrix where rows are VLM vectors% camera - 1 letter string indicateing camera% test_string - 1 string naming the test% test_version - 1 string naming test version% lmrkname - row vector of strings containing lmrkname naming scheme (use% cells)% res_name - row vector of strings containing resolution naming scheme (use% cells)% azimuth and zenith inputs are vectors (not strings)function Kristofer = Master_Sumfiles(azimuth_sc, zenith_sc, azimuth_sun, zenith_sun, distance_sc_vec, BENNU2LMRK_mat, camera, test_string, test_version, lmrk_name, res_name)distance_sc_vec = distance_sc_vec'; size_d = size(distance_sc_vec);BENNU2LMRK_mat = BENNU2LMRK_mat'; size_m = size(BENNU2LMRK_mat);camera = camera; test_string = test_string; test_version = test_version; lmrk_name = lmrk_name; res_name = res_name; date = char(datetime('now'));scazi = azimuth_sc;sczen = zenith_sc;sunazi = azimuth_sun;sunzen = zenith_sun;i = 3; fprintf( 'Test - %s\n', test_string)fprintf( 'Camera - %s\n', camera)fprintf( 'Image Version - %s\n', test_version)fprintf( 'Date - %s\n', date)fprintf('\n')fprintf( '| image_# | sc_azi | sc_zen | sun_azi | sun_zen | lmrk lat Elon | res_name res_# (cm) |\n')fprintf( '|--------------------------------------------------------------------------------------------------------------------|\n')for n = 1:size_m(2); for azimuth_sc = scazi; for zenith_sc = sczen; for azimuth_sun = sunazi; for zenith_sun = sunzen; for b = 1:size_d(2); BENNU2LMRK = BENNU2LMRK_mat(:,n); distance_sc = distance_sc_vec(b); i = i+1; [ SCOBJ, CX, CY, CZ, SZ, lat, lon, res_numb] = Dirty_SUMFILES_f( BENNU2LMRK, azimuth_sc, zenith_sc, azimuth_sun, zenith_sun, distance_sc); UTC = datetime(1993,07,31,12,0,0); UTC = datestr(UTC, 'yyyy mmm dd HH:MM:SS.FFF'); tstring1 = sprintf('~/send/DS_DN_FILES/DIRTYSUMFILES/%s%s%s%s%s%04.0f.SUM', camera, test_version, test_string, char(lmrk_name(n)), char(res_name(b)), i); tstring2 = sprintf('~/send/DS_DN_FILES/DIRTYNOMINALS/%s%s%s%s%s%04.0f.NOM', camera, test_version, test_string, char(lmrk_name(n)), char(res_name(b)), i); fid1 = fopen(tstring1, 'w+'); fprintf( fid1, '%s%s%s%s%s%04.0f\n', camera, test_version, test_string, char(lmrk_name(n)), char(res_name(b)), i); fprintf( fid1, '%s\n', UTC); fprintf( fid1, ' 1024 1024 5 16383 NPX, NLN, THRSH\n'); fprintf( fid1, ' 0.6110000000D+03 0.5115000000D+03 0.5115000000D+03 MMFL, CTR\n'); if SCOBJ(1) < 0 fprintf( fid1, ' %0.10e', SCOBJ(1)); else fprintf( fid1, ' %0.10e', SCOBJ(1)); end if SCOBJ(2) < 0 fprintf( fid1, ' %0.10e', SCOBJ(2)); else fprintf( fid1, ' %0.10e', SCOBJ(2)); end if SCOBJ(3) < 0 fprintf( fid1, ' %0.10e SCOBJ\n', SCOBJ(3)); else fprintf( fid1, ' %0.10e SCOBJ\n', SCOBJ(3)); end if CX(1) < 0 fprintf( fid1, ' %0.10e', CX(1)); else fprintf( fid1, ' %0.10e', CX(1)); end if CX(2) < 0 fprintf( fid1, ' %0.10e', CX(2)); else fprintf( fid1, ' %0.10e', CX(2)); end if CX(3) < 0 fprintf( fid1, ' %0.10e CX\n', CX(3)); else fprintf( fid1, ' %0.10e CX\n', CX(3)); end if CY(1) < 0 fprintf( fid1, ' %0.10e', CY(1)); else fprintf( fid1, ' %0.10e', CY(1)); end if CY(2) < 0 fprintf( fid1, ' %0.10e', CY(2)); else fprintf( fid1, ' %0.10e', CY(2)); end if CY(3) < 0 fprintf( fid1, ' %0.10e CY\n', CY(3)); else fprintf( fid1, ' %0.10e CY\n', CY(3)); end if CZ(1) < 0 fprintf( fid1, ' %0.10e', CZ(1)); else fprintf( fid1, ' %0.10e', CZ(1)); end if CZ(2) < 0 fprintf( fid1, ' %0.10e', CZ(2)); else fprintf( fid1, ' %0.10e', CZ(2)); end if CZ(3) < 0 fprintf( fid1, ' %0.10e CZ\n', CZ(3)); else fprintf( fid1, ' %0.10e CZ\n', CZ(3)); end if SZ(1) < 0 fprintf( fid1, ' %0.10e', SZ(1)); else fprintf( fid1, ' %0.10e', SZ(1)); end if SZ(2) < 0 fprintf( fid1, ' %0.10e', SZ(2)); else fprintf( fid1, ' %0.10e', SZ(2)); end if SZ(3) < 0 fprintf( fid1, ' %0.10e SZ\n', SZ(3)); else fprintf( fid1, ' %0.10e SZ\n', SZ(3)); end fprintf( fid1, ' 117.64700 0.00000 0.00000 0.00000 117.64700 0.00000 K-MATRIX\n'); fprintf( fid1, ' 0.00000D+00 0.00000D+00 0.00000D+00 0.00000D+00 DISTORTION\n'); fprintf( fid1, ' 0.1000000000D+01 0.1000000000D+01 0.1000000000D+01 SIGMA_VSO\n'); fprintf( fid1, ' 0.1000000000D-02 0.1000000000D-02 0.1000000000D-02 SIGMA_PTG\n'); fprintf( fid1, 'LANDMARKS\n'); fprintf( fid1, 'LIMB FITS\n'); fprintf( fid1, 'END FILE\n'); fclose( fid1); fid2 = fopen(tstring2, 'w+'); fprintf( fid2, '%s%s%s%s%s%04.0f\n', camera, test_version, test_string, char(lmrk_name(n)), char(res_name(b)), i); fprintf( fid2, ' -0.9755099111D+00 0.2079443023D+00 -0.7169086808D-01 BOD_FRAME\n'); if SCOBJ(1) < 0 fprintf( fid2, ' %0.10e', SCOBJ(1)); else fprintf( fid2, ' %0.10e', SCOBJ(1)); end if SCOBJ(2) < 0 fprintf( fid2, ' %0.10e', SCOBJ(2)); else fprintf( fid2, ' %0.10e', SCOBJ(2)); end if SCOBJ(3) < 0 fprintf( fid2, ' %0.10e SCOBJ\n', SCOBJ(3)); else fprintf( fid2, ' %0.10e SCOBJ\n', SCOBJ(3)); end fprintf(fid2, ' 0.1000000000D+01 0.1000000000D+01 0.1000000000D+01 SIGMA_VSO\n'); if CX(1) < 0 fprintf( fid2, ' %0.10e', CX(1)); else fprintf( fid2, ' %0.10e', CX(1)); end if CX(2) < 0 fprintf( fid2, ' %0.10e', CX(2)); else fprintf( fid2, ' %0.10e', CX(2)); end if CX(3) < 0 fprintf( fid2, ' %0.10e CX\n', CX(3)); else fprintf( fid2, ' %0.10e CX\n', CX(3)); end if CY(1) < 0 fprintf( fid2, ' %0.10e', CY(1)); else fprintf( fid2, ' %0.10e', CY(1)); end if CY(2) < 0 fprintf( fid2, ' %0.10e', CY(2)); else fprintf( fid2, ' %0.10e', CY(2)); end if CY(3) < 0 fprintf( fid2, ' %0.10e CY\n', CY(3)); else fprintf( fid2, ' %0.10e CY\n', CY(3)); end if CZ(1) < 0 fprintf( fid2, ' %0.10e', CZ(1)); else fprintf( fid2, ' %0.10e', CZ(1)); end if CZ(2) < 0 fprintf( fid2, ' %0.10e', CZ(2)); else fprintf( fid2, ' %0.10e', CZ(2)); end if CZ(3) < 0 fprintf( fid2, ' %0.10e CZ\n', CZ(3)); else fprintf( fid2, ' %0.10e CZ\n', CZ(3)); end fprintf( fid2, ' 0.1000000000D-02 0.1000000000D-02 0.1000000000D-02 SIGMA_PTG\n'); fprintf( fid2, 'END FILE'); fclose('all'); fprintf('| %04.0f | %03.0f | %02.0f | %03.0f | %02.0f | %s %+07.3f %07.3f | %s %03.3f |\n', i , azimuth_sc, zenith_sc, azimuth_sun, zenith_sun, char(lmrk_name(n)), lat*180/pi, lon*180/pi, char(res_name(b)), res_numb*100000) end end end end endendKristofer = 'da bomb';end

Dirty_SUMFILES_f.m

function [ SCOBJ, CX, CY, CZ, SZ, lat, lon, res_numb] = Dirty_Sumfiles( BENNU2LMRK, azimuth_sc, zenith_sc, azimuth_sun, zenith_sun, distance_sc )% Important: % azimuth and zenith angle inputs are in a NEZ (North, East, Zenith) frame% centered on the landmark.% Transforming the spherical cordinates of sc in NEZ frame to cartesian% coordinates of sc in NEZ frame (km)x_sc = distance_sc*sind(zenith_sc)*cosd(azimuth_sc);y_sc = distance_sc*sind(zenith_sc)*sind(azimuth_sc);z_sc = distance_sc*cosd(zenith_sc);% Making the x coordinate negative so the frame becomes SEZ (km)x_sc = -x_sc;% Transformation matrix that transforms SEZ to BF r = norm(BENNU2LMRK); lat = acos(BENNU2LMRK(3)/r);lon = atan2(BENNU2LMRK(2),BENNU2LMRK(1));if lat > pi/2; lat = -(lat - pi/2);else lat = pi/2 - lat;endif lon < 0; lon = lon+2*pi;else lon = lon;endQxx_mat = inv([ sin(lat)*cos(lon), sin(lat)*sin(lon), -cos(lat); ... -sin(lon), cos(lon), 0; cos(lat)*cos(lon), cos(lat)*sin(lon),... sin(lat) ]); % Landmark to SC vector in BF calculation (km)HOHO = Qxx_mat*[ x_sc; y_sc; z_sc];% Calculating SC to landmark unit vector in BF frame (km)CZ = [-HOHO(1) -HOHO(2) -HOHO(3)]/norm(HOHO);% Creating pixel unit vector from SEZ to BF (km)fro = (CZ(1)+CZ(2))/CZ(3); froyo = [-1;-1;fro]; CX = froyo/norm(froyo);% Transforming line unit vector from SEZ to BF (km)CY = cross(CZ,CX);CY = CY/norm(CY);% Vector addition to get SCOBJ in BF with orgin at center of Bennu (km)SCOBJ = HOHO + BENNU2LMRK;% Transforming SCOBJ in BF with orgin at sc (km)SCOBJ = -SCOBJ;% Transforming the spherical cordinates of the sun in SEZ frame to cartesian% coordinates of the sun in SEZ frame (km)distance_sun = 149597871;x_sun = distance_sun*sind(zenith_sun)*cosd(azimuth_sun);y_sun = distance_sun*sind(zenith_sun)*sind(azimuth_sun);z_sun = distance_sun*cosd(zenith_sun);% Making the x coordinate negative so the frame becomes SEZx_sun = -x_sun;% Landmark to Sun vector in BF calculationLugia = Qxx_mat*[ x_sun; y_sun; z_sun ];% Vector addition to get Bennu center to sun vectorBen2Sun = Lugia+BENNU2LMRK;% Bennu center to sun unit vectorSZ = Ben2Sun/norm(Ben2Sun);% Resolution numberres_numb = tan(0.0000135/2)*2*distance_sc;end