Skip to content

Commit

Permalink
Move unused python/math scripts to DEPRECATE folders
Browse files Browse the repository at this point in the history
  • Loading branch information
TCallaghan2 committed Jan 4, 2025
1 parent 75131ab commit d71e3f0
Show file tree
Hide file tree
Showing 56 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion PreProcess/PullOutProcessRecruitData.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% grp 4 as a single row.
%
% Processing continues on this array.
% - Dredge Data, if chosend, requires further processing to adjust for scallops detected vs actual
% - Dredge Data, if chosen, requires further processing to adjust for scallops detected vs actual
% and depth adjustments. HabCam needs no further adjustment.
%
% Dredge and HabCam data are combined into a single array and then sorted by year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ def Interpolate(self):
#---------------------------------------------------
# Read in grid data
#---------------------------------------------------
numGrid = self.GetNumberOfRecords(self.gridFname, hasHeader=False)
numGrid = self.GetNumberOfRecords(self.gridFname, hasHeader=True)
print('GRID LEN: ', numGrid)

gridX = np.zeros(numGrid)
gridY = np.zeros(numGrid)
gridLat = np.zeros(numGrid)
gridLon = np.zeros(numGrid)

with open(self.gridFname, 'r') as f:
inputStr = f.readline() # read and ignore header
for n in range(numGrid):
inputStr = f.readline()
#print(n, inputStr)
inputArr = [s.strip() for s in inputStr.split(',')]
gridX[n] = float(inputArr[0])
gridY[n] = float(inputArr[1])
Expand Down
File renamed without changes.
19 changes: 16 additions & 3 deletions PythonScripts/GUI/GeoSAM/GeoSams.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ def Run_Sim(self):

if result.returncode == 0:
if not self.skipStatusMsgs.get(): messagebox.showinfo("GeoSAM Sim",
f'Completed Successfully\n{result.args}\nStarting UK Interp\nIf all output selected this will run over an hour.\nPlease be patient.')
f'Completed Successfully\n{result.args}\nStarting Interp&Plot\nIf all output selected this will run over an hour.\nPlease be patient.')

# Then Continue with Interpolation and Plotting Results -----------------------------------------------------------
(retDict, procID) = self.InterpAndPlotResults()
if sum(retDict.values()) == 0:
messagebox.showinfo("GeoSAMS/UK/Plotting", f'ALL DONE\nRan {procID} processes')
messagebox.showinfo("GeoSAMS/Interp/Plotting", f'ALL DONE\nRan {procID} processes')
else:
messagebox.showerror("InterpAndPlotResults", 'Failed')
else:
Expand Down Expand Up @@ -472,6 +472,8 @@ def InterpAndPlotResults(self):
# Intepolate using OK
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# all survey data residuals computed now to interpolate.
# At this point all parallel processing is complete, restart procID counter
procID = 0
for pStr in self.paramStr:
for r in region:
for year in years:
Expand All @@ -486,6 +488,17 @@ def InterpAndPlotResults(self):
cmd = ['python3', ex, inputFile ]
with open(stdOutFile, 'w') as fid:
result = subprocess.run(cmd, stdout=fid)

retDict[procID] = result.returncode

# could wait until all scripts have run. If failure most likely with python itself
# so fail at first occurance.
if sum(retDict.values()) != 0:
messagebox.showerror("GeoSAM OK", f'Failed\n{result.args}\nReturn Code = {result.returncode}')
return (retDict, procID)
procID += 1


#
# Process CSV files to combine the years
pfix = 'Results/Lat_Lon_Grid_'
Expand All @@ -506,7 +519,7 @@ def InterpAndPlotResults(self):

if r == region[0]:
dfFinal.to_csv(flout, index=False)
else:
else: # append MA to GB
dfFinal.to_csv(flout, mode='a', index=False,header=False)

# Lat_Lon_Grid_BIOM_AL2022_2026.csv
Expand Down
Binary file modified docs/GeoSamsStartup.docx
Binary file not shown.
2 changes: 2 additions & 0 deletions mfiles/CheckInRegionPolygon.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function [zone, region]= CheckInRegionPolygon(isOctave, X_t, Y_t, shape)
% Called from HabCamData5mmbin and TrawlData5mmbin
%
% Takes X,Y UTM coordinates and determins which, if any
% Zone region geopoint is located.
% Returns Zone name and alphabetical index
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions mfiles/ZvsRCurve.m → mfiles/DEPRECATE/ZvsRCurve.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[z,j]=sort(z);r=r(j);
plot(z,r,'k.');
n=0;
for z0=0:250,
for z0=0:250
n=n+1;
k=find(and(z<z0+5,z>z0-5));
if ~isempty(k)
r0(n)=max(r(k));
else
r0(n)=NaN;
endif
endfor
end
end
z0=0:250;
close all
clf; plot(z,r,'k.',z0,r0,'r');
Expand All @@ -24,7 +24,7 @@
b=15;
fr=a+b*exp(-((z-zc)/w).^2);
j=find(r>fr);
length(j)/length(z)
length(j)/length(z);
clf; plot(z,r,'k.',z,fr,'r',z0,r0,'b',z(j),r(j),'rx');title(num2str(length(j)/length(z)))

figure
Expand All @@ -35,15 +35,15 @@
[z,j]=sort(z);r=r(j);
plot(z,r,'k.');
n=0;
for z0=0:250,
for z0=0:250
n=n+1;
k=find(and(z<z0+5,z>z0-5));
if ~isempty(k)
r0(n)=max(r(k));
else
r0(n)=NaN;
endif
endfor
end
end
z0=0:250;

clf; plot(z,r,'k.',z0,r0,'r');
Expand All @@ -58,7 +58,7 @@
fr(j)=a+b*exp(-((z(j)-zc)/w2).^2);

j=find(r>fr);
length(j)/length(z)
length(j)/length(z);
clf; plot(z,r,'k.',z,fr,'r',z0,r0,'b',z(j),r(j),'rx');title(num2str(length(j)/length(z)))


Expand All @@ -72,15 +72,15 @@
[z,j]=sort(z);r=r(j);
plot(z,r,'k.');
n=0;
for z0=0:250,
for z0=0:250
n=n+1;
k=find(and(z<z0+5,z>z0-5));
if ~isempty(k)
r0(n)=max(r(k));
else
r0(n)=NaN;
endif
endfor
end
end
z0=0:250;
figure;
clf; plot(z,r,'k.',z0,r0,'r');
Expand All @@ -95,7 +95,7 @@
fr(j)=a+b*exp(-((z(j)-zc)/w2).^2);

j=find(r>fr);
length(j)/length(z)
length(j)/length(z);
clf; plot(z,r,'k.',z,fr,'r',z0,r0,'b',z(j),r(j),'rx');title(num2str(length(j)/length(z)))


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion mfiles/GetRegion.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function x = GetRegion(isOctave, lat_t, lon_t, stratum_t)

% Called from HabCamData5mmbin and TrawlData5mmbin
%
% Determines which region, as defined by stratum, the point lat_t, lon_t is in

region_none=0;
regionGB_N=1;
Expand Down
2 changes: 2 additions & 0 deletions mfiles/GetShapeData.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function x = GetShapeData()
% Called from HabCamData5mmbin and TrawlData5mmbin
%
% reads in shape files named by environment variables
% Concatenates MAB and GB structures into a single structure
% getZone is true if the region data is desired
Expand Down
2 changes: 2 additions & 0 deletions mfiles/GetUnits.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
% or 'Lat_Lon_Survey_ABUN...'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function units = GetUnits(fileName)
% Called from PlotLatLonGridSurvey
%
units ='';
k=strfind(fileName,'ABUN');
if k>0, units = 'scallops/m^2';end
Expand Down
20 changes: 8 additions & 12 deletions mfiles/PlotXYDepth.m
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
% Reads in data From DNxyzLatLon and converts it to a table
% Reads in data From DNRegionGrid and converts it to a table
% Then plots depth using color grid

function PlotXYDepth(fname)
D=readtable(fname,"FileType","spreadsheet");

X=table2array(D(:,2));
Y=table2array(D(:,3));
[lat, lon] = utm2ll(X,Y,19);
depth=array2table(table2array(D(:,5)),'VariableNames',{'Depth'});
lon = array2table(lon,'VariableNames',{'Longitude'});
lat = array2table(lat,'VariableNames',{'Latitude'});
tbl = [lat, lon, depth];
depth_t=array2table(table2array(D(:,3)),'VariableNames',{'Depth'});
lat_t = array2table(table2array(D(:,4)),'VariableNames',{'Longitude'});
lon_t = array2table(table2array(D(:,5)),'VariableNames',{'Latitude'});
tbl = [lat_t, lon_t, depth_t];

%figure('Name',fname)
s=geoscatter(tbl,"Latitude", "Longitude", "filled");
figure('Name',fname)
s=geoscatter(tbl,"Longitude", "Latitude", "filled");
hold on
geobasemap darkwater;

s.SizeData = 5; % size of dots
s.ColorVariable = "Depth";
c=hot(100);
colormap(c);
c = colorbar;
c.Label.String = "Depth";
c.Label.String = "Depth";

0 comments on commit d71e3f0

Please sign in to comment.