-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
141 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
# Introduction | ||
# Rivercatch | ||
 | ||
|
||
This is a template software project repository used by the Earth Science focused [Intermediate Research Software Development Skills In Python](https://carpentries-incubator.github.io/python-intermediate-development-earth-sciences) course. | ||
RiverCatch is a data management system written in Python that manages measurement data collected in river catchment surveys and campaigns. | ||
|
||
## Purpose | ||
## Main Features | ||
Here are some key features of Inflam: | ||
|
||
This repository is intended to be used as a code template which is copied by learners at [Intermediate Research Software Development Skills In Python](https://carpentries-incubator.github.io/python-intermediate-development-earth-sciences) workshops. | ||
This can be done using the `Use this template` button towards the top right of this repo's GitHub page. | ||
- Provide basic statistical analyses of data | ||
- Ability to work on measurement data in Comma-Separated Value (CSV) format | ||
- Generate plots of measurement data | ||
- Analytical functions and views can be easily extended based on its Model-View-Controller architecture | ||
|
||
This software project is not finished, is currently failing to run and contains some code style issues. It is used as a starting point for the course - issues will be fixed and code will be added in a number of places during the course by learners in their own copies of the repository, as course topics are introduced. | ||
## Prerequisites | ||
RiverCatch requires the following Python packages: | ||
|
||
## Tests | ||
- [NumPy](https://www.numpy.org/) - makes use of NumPy's statistical functions | ||
- [Pandas](https://pandas.pydata.org/) - makes use of Panda's dataframes | ||
- [GeoPandas](https://geopandas.org/) - makes use of GeoPanda's spatial operations | ||
- [Matplotlib](https://matplotlib.org/stable/index.html) - uses Matplotlib to generate statistical plots | ||
|
||
Several tests have been implemented already, some of which are currently failing. | ||
These failing tests set out the requirements for the additional code to be implemented during the workshop. | ||
The following optional packages are required to run RiverCatch's unit tests: | ||
|
||
The tests should be run using `pytest`, which will be introduced during the workshop. | ||
- [pytest](https://docs.pytest.org/en/stable/) - RiverCatch's unit tests are written using pytest | ||
- [pytest-cov](https://pypi.org/project/pytest-cov/) - Adds test coverage stats to unit testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 24, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import pandas.testing as pdt\n", | ||
"from catchment.models import daily_mean\n", | ||
"import datetime\n", | ||
"import pytest" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"test_input = pd.DataFrame(\n", | ||
" data=[[1.0, 2.0],\n", | ||
" [3.0, 4.0],\n", | ||
" [5.0, 6.0]],\n", | ||
" index=[pd.to_datetime('2000-01-01 01:00'),\n", | ||
" pd.to_datetime('2000-01-01 02:00'),\n", | ||
" pd.to_datetime('2000-01-01 03:00')],\n", | ||
" columns=['A', 'B']\n", | ||
")\n", | ||
"test_result = pd.DataFrame(\n", | ||
" data=[[3.0, 4.0]],\n", | ||
" index=[datetime.date(2000, 1, 1)],\n", | ||
" columns=['A', 'B']\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 19, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"test_output = pd.DataFrame(\n", | ||
" data=[[3.0, 3.0]],\n", | ||
" index=[datetime.date(2000, 1, 1)],\n", | ||
" columns=['A', 'B'] \n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pdt.assert_frame_equal(daily_mean(test_input), test_result)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Union | ||
|
||
flag : bool = True | ||
|
||
def greet(name : str) -> None: | ||
"""Say hello to everyone""" | ||
print("Hi " + name) | ||
|
||
greet("Manchester") | ||
greet("Steven") | ||
|
||
def myAbs(x : float) -> float: | ||
"""Take the absolute of the floating-point input""" | ||
if x < 0: | ||
return (-x) | ||
else: | ||
return (x) | ||
|
||
|
||
myAbs(12) | ||
|
||
def greetAll(names : list[str]) -> None: | ||
for name in names: | ||
greet(name) | ||
|
||
greetAll(["Alice", "John", "Joe"]) | ||
|
||
#greetAll([12, 12]) | ||
|
||
some_data : tuple[int, bool, str] = (41, True, "Manchester") | ||
#some_other_data : tuple[int, bool, str] = (41, 232132, "Manchester") | ||
|
||
def myDiv(x : float, y : float) -> Union[float, None]: | ||
if y != 0: return x/y | ||
else: return None | ||
|
||
|
||
myDict : dict[str, Union[float, str]] = {"temp": 273.0, "units": "Kelvin"} | ||
|
||
#reveal_type(len) | ||
|