We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/aaron-schroeder/personal_site/blob/fab414763ea7a47c72bf649e43b2888a70c076dd/trips/models.py#L392-L446
with self.csv_file.open('r') as f: records = pd.read_csv(f) activity = Activity(records) if activity.has_streams('elevation'): elevation_ft = activity.elevation.stream * 5280 / 1609.34 else: return None if activity.has_streams('distance'): distance_mi = activity.distance.stream / 1609.34 elif activity.has_position: distance_mi = activity.distance.records_from_position() / 1609.34 else: return None
https://github.com/aaron-schroeder/personal_site/blob/fab414763ea7a47c72bf649e43b2888a70c076dd/trips/models.py#L449-#L494
with self.csv_file.open('r') as f: records = pd.read_csv(f) activity = Activity(records) # activity = Activity.from_csv(self.csv_file.path) # if not activity.has_position: if not 'lat' in records.columns or not 'lon' in records.columns: return None # Convert from SI to imperial units. if activity.has_streams('distance'): records['distance_mi'] = activity.distance.stream / 1609.34 else: records['distance_mi'] = activity.distance.records_from_position() if activity.has_streams('elevation'): records['elevation_ft'] = activity.elevation.stream * 5280 / 1609.34 customdata = records[['distance_mi', 'elevation_ft']] hovertemplate = ( 'Distance: %{customdata[0]:.2f} mi<br>' 'Elevation: %{customdata[1]:.1f} ft<extra></extra>' ) else: customdata = records['distance_mi'] hovertemplate = 'Distance: %{customdata:.2f} mi<extra></extra>'
https://github.com/aaron-schroeder/personal_site/blob/51170b1ca18d25c44037c290aa26cc03ef178ce6/trips/util.py
def file_to_activity(uploaded_file): fname = uploaded_file.name file_obj = uploaded_file.read() if fname.lower().endswith('fit'): activity = Activity.from_fit(file_obj) elif fname.lower().endswith('tcx'): activity = Activity.from_tcx(file_obj) elif fname.lower().endswith('gpx'): activity = Activity.from_gpx(file_obj) else: # maybe return some error or something...a redirect? activity = Activity(pd.DataFrame([])) return activity def get_data(activity): data = dict() tz_local = pytz.timezone('America/Denver') data['date'] = { src: activity.timestamp.start(src).astimezone(tz_local).date().strftime('%Y-%m-%d') for src in ('records', 'summary', 'laps') if activity.timestamp.start(src) is not None } data['distance_mi'] = { src: round(activity.distance.total(src) / 1609.34, 2) for src in ('records', 'position', 'summary', 'laps') if activity.distance.total(src) is not None } data['elev_gain_ft'] = { src: round(activity.elevation.gain(src) * 5280 / 1609.34, 0) for src in ('records', 'summary', 'laps') if activity.elevation.gain(src) is not None } data['elev_loss_ft'] = { src: round(activity.elevation.loss(src) * 5280 / 1609.34, 0) for src in ('records', 'summary', 'laps') if activity.elevation.loss(src) is not None } for coord in ['lat', 'lon']: if activity.has_position: accessor = getattr(activity, coord) data[coord] = { 'center': round(accessor.center, 6), 'start': round(accessor.stream.iloc[0], 6), 'end': round(accessor.stream.iloc[-1], 6) } else: data[coord] = dict() return data def file_to_csv(uploaded_file): activity = file_to_activity(uploaded_file) # TODO: should I have the plotting method do that? if not activity.has_streams('distance') and activity.has_position: # Behind the scenes, this calc uses pandas-xyz: activity.distance.records_from_position(inplace=True) return ContentFile( activity.records.to_csv(), name=f'{os.path.splitext(os.path.basename(uploaded_file.name))[0]}.csv' )
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/make_hist_grade.py
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/make_profile.py
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/wrangling.py
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://github.com/aaron-schroeder/personal_site/blob/fab414763ea7a47c72bf649e43b2888a70c076dd/trips/models.py#L392-L446
https://github.com/aaron-schroeder/personal_site/blob/fab414763ea7a47c72bf649e43b2888a70c076dd/trips/models.py#L449-#L494
https://github.com/aaron-schroeder/personal_site/blob/51170b1ca18d25c44037c290aa26cc03ef178ce6/trips/util.py
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/make_hist_grade.py
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/make_profile.py
https://github.com/aaron-schroeder/pemberton-course-analysis/blob/872257e4f9e295820a414d36237c23db5cf2356e/wrangling.py
The text was updated successfully, but these errors were encountered: