Skip to content
New issue

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

MAINT: avoid using marker terminology #176

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
- Rename section `dirs` to `paths`.
- Remove `general.run_id`.
- Rename some main modules to make naming more logical with non-cropclassification
markers being added (#162)
detections being added (#162)

### Improvements

- Add feature "cross-prediction-models" to avoid markers being calculated on parcels
using a model that used this parcel in its training (#142, #143)
- Add feature "cross-prediction-models" to be able to avoid classifications being
calculated on parcels using a model that used this parcel in its training (#142, #143)
- Consolidated some landcover pre-processing ignore codes (#120)
- Add some extra global accuracies (precision, recall, f1) to report (#119)
- Add option `images.on_missing_images` to be able to ignore errors in the
Expand Down Expand Up @@ -77,8 +77,9 @@
- Improve configurability + defaults of keras mlp classifier (#115)
- Make image profiles to be used in a classification configurable in a config file (#56)
- Add option to overrule configuration parameters at runtime (#92)
- If image period is e.g. "weekly", align `start_date` of a marker to the next monday
instead of the previous one to avoid using data outside the dates provided (#83, #84)
- If image period is e.g. "weekly", align `start_date` of the timeseries data used in a
detection to the next monday instead of the previous one to avoid using data outside
the dates provided (#83, #84)
- Add method "best available pixel" on openeo for S2 (#70)
- Add utility script to recalculate reports for an existing run + make recalculation
more robust for old runs (#91, #102, #103, #104, #106)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Mind: the sentinel CARD image structure as expected for timeseries calculation d

5. Start a crop classification

Run `cropclassification -t <tasks_dir>`, with a 'calc_marker' type of task in the tasks dir.
Run `cropclassification -t <tasks_dir>`, with a 'calc_cropclass' type of task in the tasks dir.
2 changes: 1 addition & 1 deletion bin_util/calc_periodic_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():

image_profiles_path = (
Path(__file__).resolve().parent.parent
/ "markers/_config/image_profiles.ini"
/ "monitoring/_config/image_profiles.ini"
)
imageprofiles = conf._get_image_profiles(image_profiles_path)

Expand Down
2 changes: 1 addition & 1 deletion cropclassification/calc_cropclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run_cropclass(
default_basedir: Path,
config_overrules: list[str] = [],
):
"""Runs a crop classification marker using the setting in the config_paths.
"""Runs a crop classification using the setting in the config_paths.

Args:
config_paths (List[Path]): the config files to load
Expand Down
12 changes: 6 additions & 6 deletions cropclassification/general.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This is a config file with the shared/default settings for all markers.
# This is a config file with the shared/default settings for all detections.

# The task section contains information about the task you want to run
[task]

# The action you want to run:
# - calc_timeseries: calculate a Sentinel timeseries for a file with polygons
# - calc_maker: calculate a marker
# - calc_periodic_mosaic: calculate periodic mosai
# - calc_cropclass: run a crop classification
# - calc_periodic_mosaic: create periodic mosaic images
action = MUST_OVERRIDE

# Extra config files to load, in addition to general defaults.
Expand Down Expand Up @@ -161,19 +161,19 @@ min_nb_pixels_train = ${marker:min_nb_pixels}

# classes that will be ignored for training + won't receive a prediction
classes_to_ignore = ${classes_to_ignore_default}
# define default ignores here, so it is easy to ADD extra for specific markers
# define default ignores here, so it is easy to ADD extra for specific classifications
classes_to_ignore_default = IGNORE_DIFFICULT_PERMANENT_CLASS, IGNORE_UNIMPORTANT, IGNORE_NOT_ENOUGH_SAMPLES, IGNORE_EARLY_CROP, IGNORE_LATE_CROP, IGNORE_LATE_MAINCROP, IGNORE_NEW_GRASSLAND, IGNORE_NOT_DECLARED

# classes that should be ignored for training, but have to get a prediction
classes_to_ignore_for_train = ${classes_to_ignore_for_train_default}
# define default ignores here, so it is easy to ADD extra for specific markers
# define default ignores here, so it is easy to ADD extra for specific classifications
classes_to_ignore_for_train_default = UNKNOWN

# classes that should specified as unimportant in the reporting
# Remark: this doesn't influence the training or predicting, these need to be set in
# the other paremeters!
classes_to_ignore_unimportant = ${classes_to_ignore_unimportant_default}
# define default ignores here, so it is easy to ADD extra for specific markers
# define default ignores here, so it is easy to ADD extra for specific classifications
classes_to_ignore_unimportant_default = IGNORE_UNIMPORTANT, IGNORE_LATE_MAINCROP, IGNORE_NOT_DECLARED

# strategy to balance the training dataset for the marker. Possible values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"VH"
],
"time_reducer": "first",
"path": "C:/Users/local_PIEROG/Temp/1/pytest-of-PIEROG/pytest-5/test_calc_periodic_mosaic_loca0/markers/periodic_mosaic/roi_test/s1-grd-sigma0-asc/s1-grd-sigma0-asc_2024-03-04_2024-03-10_VV-VH_first.tif",
"path": "C:/Users/local_PIEROG/Temp/1/pytest-of-PIEROG/pytest-5/test_calc_periodic_mosaic_loca0/monitoring/periodic_mosaic/roi_test/s1-grd-sigma0-asc/s1-grd-sigma0-asc_2024-03-04_2024-03-10_VV-VH_first.tif",
"orbit": "asc"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"VH"
],
"time_reducer": "last",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/markers/_images_periodic/BEFL/s1-grd-sigma0-asc-weekly/s1-grd-sigma0-asc-weekly_2024-03-11_2024-03-17_VV-VH_last.tif",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/monitoring/_images_periodic/BEFL/s1-grd-sigma0-asc-weekly/s1-grd-sigma0-asc-weekly_2024-03-11_2024-03-17_VV-VH_last.tif",
"job_options": null,
"process_options": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"VH"
],
"time_reducer": "first",
"path": "C:/Users/local_PIEROG/Temp/1/pytest-of-PIEROG/pytest-5/test_calc_periodic_mosaic_loca0/markers/periodic_mosaic/roi_test/s1-grd-sigma0-desc/s1-grd-sigma0-desc_2024-03-04_2024-03-10_VV-VH_first.tif",
"path": "C:/Users/local_PIEROG/Temp/1/pytest-of-PIEROG/pytest-5/test_calc_periodic_mosaic_loca0/monitoring/periodic_mosaic/roi_test/s1-grd-sigma0-desc/s1-grd-sigma0-desc_2024-03-04_2024-03-10_VV-VH_first.tif",
"orbit": "desc"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"VH"
],
"time_reducer": "last",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/markers/_images_periodic/BEFL/s1-grd-sigma0-desc-weekly/s1-grd-sigma0-desc-weekly_2024-03-11_2024-03-17_VV-VH_last.tif",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/monitoring/_images_periodic/BEFL/s1-grd-sigma0-desc-weekly/s1-grd-sigma0-desc-weekly_2024-03-11_2024-03-17_VV-VH_last.tif",
"job_options": null,
"process_options": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"B12"
],
"time_reducer": "mean",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/markers/_images_periodic/BEFL/s2-agri-weekly/s2-agri-weekly_2024-03-11_2024-03-17_B02-B03-B04-B08-B11-B12_mean.tif",
"path": "C:/Users/local_KRIWAY/Temp/1/pytest-of-KRIWAY/pytest-36/test_end2end0/monitoring/_images_periodic/BEFL/s2-agri-weekly/s2-agri-weekly_2024-03-11_2024-03-17_B02-B03-B04-B08-B11-B12_mean.tif",
"job_options": {
"driver-memoryOverhead": "5G"
},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_read_config():
]
conf.read_config(
config_paths=config_paths,
default_basedir=SampleData.markers_dir,
default_basedir=SampleData.base_dir,
overrules=[
"paths.images_periodic_dir=_satellite_periodic/BEFL",
],
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_read_config_overrule():
config_paths = SampleData.config_dir / "cropgroup.ini"
conf.read_config(
config_paths=config_paths,
default_basedir=SampleData.markers_dir,
default_basedir=SampleData.base_dir,
overrules=[
"roi.roi_name=ROI_NAME_TEST",
"paths.images_periodic_dir=_satellite_periodic/BEFL",
Expand Down
16 changes: 8 additions & 8 deletions tests/test_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_task_calc_marker(tmp_path, balancing_strategy, cross_pred_models):
if not HAS_QGIS:
pytest.skip("QGIS is needed for timeseries calculation, but is not available.")

markers_dir = tmp_path / test_helper.SampleData.markers_dir.name
shutil.copytree(test_helper.SampleData.markers_dir, markers_dir)
base_dir = tmp_path / test_helper.SampleData.base_dir.name
shutil.copytree(test_helper.SampleData.base_dir, base_dir)

# Create configparser and read task file!
tasks_dir = markers_dir / "_tasks"
tasks_dir = base_dir / "_tasks"
ignore_dir = tasks_dir / "ignore"
task_ini = "task_test_calc_marker.ini"

Expand All @@ -44,7 +44,7 @@ def test_task_calc_marker(tmp_path, balancing_strategy, cross_pred_models):
)

today_str = datetime.now().strftime("%Y-%m-%d")
run_dir = markers_dir / f"2024_CROPGROUP/Run_{today_str}_001"
run_dir = base_dir / f"2024_CROPGROUP/Run_{today_str}_001"
assert run_dir.exists()
base_stem = "Prc_BEFL_2023_2023-07-24_bufm5_weekly_predict_all"
assert (run_dir / f"{base_stem}.gpkg").exists()
Expand All @@ -71,10 +71,10 @@ def test_task_calc_marker(tmp_path, balancing_strategy, cross_pred_models):


def test_task_calc_periodic_mosaic(tmp_path):
markers_dir = tmp_path / test_helper.SampleData.markers_dir.name
shutil.copytree(test_helper.SampleData.markers_dir, markers_dir)
base_dir = tmp_path / test_helper.SampleData.base_dir.name
shutil.copytree(test_helper.SampleData.base_dir, base_dir)
# Create configparser and read task file!
tasks_dir = markers_dir / "_tasks"
tasks_dir = base_dir / "_tasks"
ignore_dir = tasks_dir / "ignore"
task_ini = "task_test_calc_periodic_mosaic.ini"

Expand All @@ -83,6 +83,6 @@ def test_task_calc_periodic_mosaic(tmp_path):
taskrunner.run_tasks(tasksdir=tasks_dir)

# Check if a log file was written
log_dir = markers_dir / "log"
log_dir = base_dir / "log"
assert log_dir.exists()
assert len(list(log_dir.glob("*.log"))) == 1
14 changes: 7 additions & 7 deletions tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@


class SampleData:
markers_dir = Path(__file__).resolve().parent.parent / "markers"
tasks_dir = markers_dir / "_tasks"
config_dir = markers_dir / "_config"
inputdata_dir = markers_dir / "_inputdata"
refe_dir = markers_dir / "_refe"
image_dir = markers_dir / "_images_periodic"
input_dir = markers_dir / "_inputdata"
base_dir = Path(__file__).resolve().parent.parent / "monitoring"
tasks_dir = base_dir / "_tasks"
config_dir = base_dir / "_config"
inputdata_dir = base_dir / "_inputdata"
refe_dir = base_dir / "_refe"
image_dir = base_dir / "_images_periodic"
input_dir = base_dir / "_inputdata"
roi_name = "roi_test"
image_roi_dir = image_dir / roi_name

Expand Down
4 changes: 2 additions & 2 deletions tests/test_mosaic_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def test_calc_periodic_mosaic_s2(tmp_path):
# Prepare test data
sample_dir = SampleData.markers_dir
sample_dir = SampleData.base_dir
test_dir = tmp_path / sample_dir.name
shutil.copytree(sample_dir, test_dir)

Expand Down Expand Up @@ -48,7 +48,7 @@ def test_calc_periodic_mosaic_s2(tmp_path):

def test_calc_periodic_mosaic_s1_local_index_dprvi(tmp_path):
# Prepare test data
sample_dir = SampleData.markers_dir
sample_dir = SampleData.base_dir
test_dir = tmp_path / sample_dir.name
shutil.copytree(sample_dir, test_dir)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_zonal_stats_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_zonal_stats_bulk(tmp_path, engine):
pytest.skip("QGIS is not available on this system.")

# Prepare test data
sample_dir = SampleData.markers_dir
sample_dir = SampleData.base_dir
test_dir = tmp_path / sample_dir.name
shutil.copytree(sample_dir, test_dir)

Expand Down
Loading