From 7642c39197836f3a76fe3ec25ad8a0e2656bbcf5 Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Thu, 21 Mar 2019 16:17:45 -0500 Subject: [PATCH] working --- .../data/SandstormCargoShipBalls.csv | 3 - .../data/SandstormCargoShipHatches.csv | 3 - .../data/SandstormLowerRocketBalls.csv | 3 - .../data/SandstormLowerRocketHatches.csv | 3 - .../data/SandstormUpperRocketBalls.csv | 3 - .../data/SandstormUpperRocketHatches.csv | 3 - data analysis/data/TeleopCargoShipBalls.csv | 3 - data analysis/data/TeleopCargoShipHatches.csv | 3 - data analysis/data/TeleopLowerRocketBalls.csv | 3 - .../data/TeleopLowerRocketHatches.csv | 3 - data analysis/data/TeleopUpperRocketBalls.csv | 3 - .../data/TeleopUpperRocketHatches.csv | 3 - data analysis/data/cargoBalls.csv | 3 - data analysis/data/hatchPanels.csv | 3 - data analysis/data/match.csv | 3 - data analysis/data/notes.csv | 3 - data analysis/data/observationType.csv | 3 - data analysis/data/teamDBRef.csv | 3 - data analysis/superscript.py | 69 +++++++------------ 19 files changed, 24 insertions(+), 99 deletions(-) delete mode 100644 data analysis/data/SandstormCargoShipBalls.csv delete mode 100644 data analysis/data/SandstormCargoShipHatches.csv delete mode 100644 data analysis/data/SandstormLowerRocketBalls.csv delete mode 100644 data analysis/data/SandstormLowerRocketHatches.csv delete mode 100644 data analysis/data/SandstormUpperRocketBalls.csv delete mode 100644 data analysis/data/SandstormUpperRocketHatches.csv delete mode 100644 data analysis/data/TeleopCargoShipBalls.csv delete mode 100644 data analysis/data/TeleopCargoShipHatches.csv delete mode 100644 data analysis/data/TeleopLowerRocketBalls.csv delete mode 100644 data analysis/data/TeleopLowerRocketHatches.csv delete mode 100644 data analysis/data/TeleopUpperRocketBalls.csv delete mode 100644 data analysis/data/TeleopUpperRocketHatches.csv delete mode 100644 data analysis/data/cargoBalls.csv delete mode 100644 data analysis/data/hatchPanels.csv delete mode 100644 data analysis/data/match.csv delete mode 100644 data analysis/data/notes.csv delete mode 100644 data analysis/data/observationType.csv delete mode 100644 data analysis/data/teamDBRef.csv diff --git a/data analysis/data/SandstormCargoShipBalls.csv b/data analysis/data/SandstormCargoShipBalls.csv deleted file mode 100644 index 45ad1826..00000000 --- a/data analysis/data/SandstormCargoShipBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,1.0 -0.0 diff --git a/data analysis/data/SandstormCargoShipHatches.csv b/data analysis/data/SandstormCargoShipHatches.csv deleted file mode 100644 index eeac11fb..00000000 --- a/data analysis/data/SandstormCargoShipHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -1.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/SandstormLowerRocketBalls.csv b/data analysis/data/SandstormLowerRocketBalls.csv deleted file mode 100644 index f738a146..00000000 --- a/data analysis/data/SandstormLowerRocketBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/SandstormLowerRocketHatches.csv b/data analysis/data/SandstormLowerRocketHatches.csv deleted file mode 100644 index eeac11fb..00000000 --- a/data analysis/data/SandstormLowerRocketHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -1.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/SandstormUpperRocketBalls.csv b/data analysis/data/SandstormUpperRocketBalls.csv deleted file mode 100644 index f738a146..00000000 --- a/data analysis/data/SandstormUpperRocketBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/SandstormUpperRocketHatches.csv b/data analysis/data/SandstormUpperRocketHatches.csv deleted file mode 100644 index f738a146..00000000 --- a/data analysis/data/SandstormUpperRocketHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/TeleopCargoShipBalls.csv b/data analysis/data/TeleopCargoShipBalls.csv deleted file mode 100644 index c9c11728..00000000 --- a/data analysis/data/TeleopCargoShipBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,5.0 -0.0 diff --git a/data analysis/data/TeleopCargoShipHatches.csv b/data analysis/data/TeleopCargoShipHatches.csv deleted file mode 100644 index 1d8e9288..00000000 --- a/data analysis/data/TeleopCargoShipHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,1.0 -1.0 diff --git a/data analysis/data/TeleopLowerRocketBalls.csv b/data analysis/data/TeleopLowerRocketBalls.csv deleted file mode 100644 index 119e509d..00000000 --- a/data analysis/data/TeleopLowerRocketBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,4.0 -0.0 diff --git a/data analysis/data/TeleopLowerRocketHatches.csv b/data analysis/data/TeleopLowerRocketHatches.csv deleted file mode 100644 index f738a146..00000000 --- a/data analysis/data/TeleopLowerRocketHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/TeleopUpperRocketBalls.csv b/data analysis/data/TeleopUpperRocketBalls.csv deleted file mode 100644 index f738a146..00000000 --- a/data analysis/data/TeleopUpperRocketBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -0.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/TeleopUpperRocketHatches.csv b/data analysis/data/TeleopUpperRocketHatches.csv deleted file mode 100644 index eb0a027a..00000000 --- a/data analysis/data/TeleopUpperRocketHatches.csv +++ /dev/null @@ -1,3 +0,0 @@ -13.0 -0.0,0.0 -0.0 diff --git a/data analysis/data/cargoBalls.csv b/data analysis/data/cargoBalls.csv deleted file mode 100644 index 91ae8f89..00000000 --- a/data analysis/data/cargoBalls.csv +++ /dev/null @@ -1,3 +0,0 @@ -10.0 -0.0,7.0 -7.0 diff --git a/data analysis/data/hatchPanels.csv b/data analysis/data/hatchPanels.csv deleted file mode 100644 index 9a0744d6..00000000 --- a/data analysis/data/hatchPanels.csv +++ /dev/null @@ -1,3 +0,0 @@ -1.0 -0.0,7.0 -0.0 diff --git a/data analysis/data/match.csv b/data analysis/data/match.csv deleted file mode 100644 index 0c4f3d44..00000000 --- a/data analysis/data/match.csv +++ /dev/null @@ -1,3 +0,0 @@ -match-23 -match-18,match-3 -match-18 diff --git a/data analysis/data/notes.csv b/data analysis/data/notes.csv deleted file mode 100644 index 026e047b..00000000 --- a/data analysis/data/notes.csv +++ /dev/null @@ -1,3 +0,0 @@ -yeeee -,si papa -nine diff --git a/data analysis/data/observationType.csv b/data analysis/data/observationType.csv deleted file mode 100644 index 8ea07c8b..00000000 --- a/data analysis/data/observationType.csv +++ /dev/null @@ -1,3 +0,0 @@ -Quantitative -Quantitative,Quantitative -Quantitative diff --git a/data analysis/data/teamDBRef.csv b/data analysis/data/teamDBRef.csv deleted file mode 100644 index 98771ec5..00000000 --- a/data analysis/data/teamDBRef.csv +++ /dev/null @@ -1,3 +0,0 @@ -team-2022 -team-16,team-16 -team-2451 diff --git a/data analysis/superscript.py b/data analysis/superscript.py index a7d36593..02a7b1bb 100644 --- a/data analysis/superscript.py +++ b/data analysis/superscript.py @@ -67,7 +67,7 @@ def titanservice(): file_list = glob.glob(source_dir + '/*.csv') #supposedly sorts by alphabetical order, skips reading teams.csv because of redundancy data = [] files = [fn for fn in glob.glob('data/*.csv') - if not (os.path.basename(fn).startswith('teams') or os.path.basename(fn).startswith('match') or os.path.basename(fn).startswith('notes') or os.path.basename(fn).startswith('observationType') or os.path.basename(fn).startswith('teamDBRef') )] #scores will be handled sperately + if not (os.path.basename(fn).startswith('teams'))] #scores will be handled sperately for i in files: data.append(analysis.load_csv(i)) @@ -89,40 +89,40 @@ def titanservice(): for i in range(len(measure)): #unpacks into specific teams - #ofbest_curve = [None] - #r2best_curve = [None] + ofbest_curve = [None] + r2best_curve = [None] line = measure[i] #print(line) - #x = list(range(len(line))) - #eqs, rmss, r2s, overfit = analysis.optimize_regression(x, line, 10, 1) + x = list(range(len(line))) + eqs, rmss, r2s, overfit = analysis.optimize_regression(x, line, 10, 1) - #beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "min_overfit") + beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "min_overfit") #print(eqs, rmss, r2s, overfit) - #ofbest_curve.append(beqs) - #ofbest_curve.append(brmss) - #ofbest_curve.append(br2s) - #ofbest_curve.append(boverfit) - #ofbest_curve.pop(0) + ofbest_curve.append(beqs) + ofbest_curve.append(brmss) + ofbest_curve.append(br2s) + ofbest_curve.append(boverfit) + ofbest_curve.pop(0) #print(ofbest_curve) - #beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "max_r2s") + beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "max_r2s") - #r2best_curve.append(beqs) - #r2best_curve.append(brmss) - #r2best_curve.append(br2s) - #r2best_curve.append(boverfit) - #r2best_curve.pop(0) + r2best_curve.append(beqs) + r2best_curve.append(brmss) + r2best_curve.append(br2s) + r2best_curve.append(boverfit) + r2best_curve.pop(0) #print(r2best_curve) - measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)) + list(analysis.histo_analysis(line, 1, -3, 3))) + measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)) + list(analysis.histo_analysis(line, 1, -3, 3)) + ofbest_curve + r2best_curve) stats.append(list(measure_stats)) nishant = [] @@ -174,18 +174,9 @@ def titanservice(): json_out = {} score_out = {} - #print(stats) - - #print(stats[0]) - - #for i in range(len(teams)): - # json_out[str(teams[i][0])] = (stats[0][i]) - for i in range(len(teams)): score_out[str(teams[i][0])] = (nishant[i]) - #print(json_out.get('5')) - location = db.collection(u'stats').document(u'stats-noNN') for i in range(len(teams)): general_general_stats = location.collection(teams[i][0]) @@ -198,26 +189,18 @@ def titanservice(): for i in range(len(teams)): nnum = location.collection(teams[i][0]).document(u'nishant_number').set({'nishant':score_out.get(teams[i][0])}) - #general_general_stats.collection().document('stats').set() - #db.collection(u'stats').document(u'stats-noNN').set(score_out) - def pulldata(): - teams = analysis.load_csv('data/teams.csv') scores = [] for i in range(len(teams)): team_scores = [] + #print(teams[i][0]) request_data_object = tba.req_team_matches(teams[i][0], 2019, "UDvKmPjPRfwwUdDX1JxbmkyecYBJhCtXeyVk9vmO2i7K0Zn4wqQPMfzuEINXJ7e5") json_data = request_data_object.json() - #print(json_data) - - for i in range(len(json_data) - 1, -1, -1): + #for i in json_data: + + # if i - if json_data[i].get('winning_alliance') == None or json_data[i].get('winning_alliance') == [] or json_data[i].get('winning_alliance') == "": - print(json_data[i]) - json_data.remove(json_data[i]) - - #print(json_data) json_data = sorted(json_data, key=lambda k: k.get('actual_time', 0), reverse=False) for j in range(len(json_data)): if "frc" + teams[i][0] in json_data[j].get('alliances').get('blue').get('team_keys'): @@ -226,8 +209,6 @@ def pulldata(): team_scores.append(json_data[j].get('alliances').get('red').get('score')) scores.append(team_scores) - print(scores) - with open("data/scores.csv", "w+", newline = '') as file: writer = csv.writer(file, delimiter = ',') writer.writerows(scores) @@ -240,17 +221,15 @@ def service(): start = time.time() - #print("[OK]" + "time is: " + time.time()) - print("[OK] starting calculations") fucked = False for i in range(0, 5): - #try: + try: titanservice() break - #except: + except: if (i != 4): print("[WARNING] failed, trying " + str(5 - i - 1) + " more times") else: