ubc-mds / noaastn Goto Github PK
View Code? Open in Web Editor NEWPython package that downloads, processes and visualizes weather data from the NOAA website.
Home Page: https://noaastn.readthedocs.io/en/latest/
License: MIT License
Python package that downloads, processes and visualizes weather data from the NOAA website.
Home Page: https://noaastn.readthedocs.io/en/latest/
License: MIT License
def plot_weather_data(obs_df, col_name, time_basis):
"""
Visualizes the weather station observations including air temperature,
atmospheric pressure, wind speed, and wind direction changing over time.
Parameters
----------
obs_df : pandas.DataFrame
A dataframe that contains a time series of weather station
observations.
col_name : str
Variables that users would like to plot on a timely basis,
including 'air_temp', 'atm_press', 'wind_spd', 'wind_dir'
time_basis : str
The users can choose to plot the observations on 'monthly' or
'daily basis'
Returns
-------
altair.vegalite.v4.api.Chart
A plot can visualize the changing of observation on the timely basis
that user chooses.
Examples
--------
>>> plot_weather_data(obs_df, col_name="air_temp", time_basis="monthly")
"""
# Test input types
assert (
type(obs_df) == pd.core.frame.DataFrame
), "Weather data should be a Pandas DataFrame."
assert type(col_name) == str, "Variable name must be entered as a string"
assert type(time_basis) == str, "Time basis must be entered as a string"
# Test edge cases
assert col_name in [
"air_temp",
"atm_press",
"wind_spd",
"wind_dir",
], "Variable can only be one of air_temp, atm_press, wind_spd or wind_dir"
assert time_basis in [
"monthly",
"daily",
], "Time basis can only be monthly or daily"
df = obs_df.dropna()
assert (
len(df.index) > 2
), "Dataset is not sufficient to visualize" # Test edge cases
year = df.datetime.dt.year[0]
title_dic = {"air_temp": "Air Temperature",
"atm_press": "Atmospheric Pressure",
"wind_spd": "Wind Speed",
"wind_dir": "Wind Direction"}
if time_basis == "monthly":
df = df.set_index("datetime").resample("M").mean().reset_index()
assert (
len(df.index) > 2
), "Dataset is not sufficient to visualize" # Test edge cases
line = (
alt.Chart(df, title= title_dic[col_name] + " for " + str(year))
.mark_line(color="orange")
.encode(
alt.X(
"month(datetime)",
title="Month",
axis=alt.Axis(labelAngle=-30),
),
alt.Y(
col_name,
title=title_dic[col_name],
scale=alt.Scale(zero=False),
),
alt.Tooltip(col_name),
)
)
else:
df = df.set_index("datetime").resample("D").mean().reset_index()
assert (
len(df.index) > 2
), "Dataset is not sufficient to visualize" # Test edge cases
line = (
alt.Chart(df, title= title_dic[col_name] + " for " + str(year))
.mark_line(color="orange")
.encode(
alt.X(
"datetime", title="Date", axis=alt.Axis(labelAngle=-30)
),
alt.Y(
col_name,
title=title_dic[col_name],
scale=alt.Scale(zero=False),
),
alt.Tooltip(col_name),
)
)
chart = (
line.properties(width=500, height=350)
.configure_axis(labelFontSize=15, titleFontSize=20, grid=False)
.configure_title(fontSize=25)
)
return chart
The discussion of license choice for this project is the same as the discussion here License choice for noaastn package
Come up with a topic for your project.
Discuss the topic with your TA or lab instructor and proceed only after your topic has been approved by one of them.
Your package documentation should be very clear by the end of this milestone and deployed by ReadTheDocs. All docstrings for all functions should be rendered using the napolean Sphinx extnesion and readable on ReadTheDocs. Your documentation should also include a demonstration of how to use each function in the package, so that any user with minimal Python expertise would be able to run your package functions and play around with them.
Your task here is to make sure the workflow in .github/workflows/deploy.yml is correctly configured so it runs the test suite, style checkers and deplys to package to test PyPI on pushes to your project's repository's deployment branch (typically the main branch). At time of submission, we expect that your project successfully runs this workflow. This should be evidenced by a green release button on your package repository's README.
A couple things you might need to change in your .github/workflows/deploy.yml file:
Ensure the deployment branch (typically the main branch) is correctly specified on lines 7
Ensure that the correct Python version is listed on line 14 (it should match the version in your pyproject.toml file)
We have created the project structure for this python project and pushed it as a public repository in the UBC-MDS organization on Github.com
The contributors' names are shared in the Contributors section of README.md file
Need to review 'CONDUCT' and 'CONTRIBUTING' file to make sure it adapts with appropriate attributions
Need to finish 'README.md' file
Your task here is to make sure the workflow in .github/workflows/build.yml is correctly configured so that at a minimum, it runs the test suite and style checkers on pushes and pull requests to your project's repository's deployment branch (typically the main branch). At time of submission, we expect that your project successfully runs this workflow.
A couple things you might need to change in your .github/workflows/build.yml file:
Ensure the deployment branch (typically the main branch) is correctly specified on lines 7 & 10
Ensure that the correct Python version is listed on lines 21 and 24 (it should match the version in your pyproject.toml file)
Each team must initiate a review request by opening an issue per package in the UBC-MDS/software-review-2021 repository.
Need to modify the test function in order to test the dynamic information
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.