ocstrack 0.1.3.post1.dev0__tar.gz → 0.1.4.post0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ocstrack-0.1.4.post0/PKG-INFO +87 -0
- ocstrack-0.1.4.post0/README.md +63 -0
- ocstrack-0.1.4.post0/examples/ADCIRCSWAN_SatAlt.py +63 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/examples/Plot_Collocated.ipynb +14 -14
- ocstrack-0.1.4.post0/examples/SCHISMWWM_SatAlt.py +64 -0
- ocstrack-0.1.4.post0/examples/SCHISM_ArgoFloat.py +81 -0
- ocstrack-0.1.4.post0/ocstrack/Collocation/collocate.py +886 -0
- ocstrack-0.1.4.post0/ocstrack/Collocation/output.py +227 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/Collocation/spatial.py +4 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/Collocation/temporal.py +38 -32
- ocstrack-0.1.4.post0/ocstrack/Model/model.py +534 -0
- ocstrack-0.1.4.post0/ocstrack/Observation/argofloat.py +222 -0
- ocstrack-0.1.4.post0/ocstrack/Observation/get_argo.py +498 -0
- {ocstrack-0.1.3.post1.dev0/ocstrack/Satellite → ocstrack-0.1.4.post0/ocstrack/Observation}/get_sat.py +2 -0
- {ocstrack-0.1.3.post1.dev0/ocstrack/Satellite → ocstrack-0.1.4.post0/ocstrack/Observation}/urls.py +4 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/_version.py +3 -3
- ocstrack-0.1.4.post0/ocstrack.egg-info/PKG-INFO +87 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack.egg-info/SOURCES.txt +9 -4
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack.egg-info/requires.txt +1 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/pyproject.toml +2 -2
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/requirements.txt +1 -0
- ocstrack-0.1.3.post1.dev0/PKG-INFO +0 -142
- ocstrack-0.1.3.post1.dev0/README.md +0 -119
- ocstrack-0.1.3.post1.dev0/ocstrack/Collocation/collocate.py +0 -443
- ocstrack-0.1.3.post1.dev0/ocstrack/Collocation/output.py +0 -66
- ocstrack-0.1.3.post1.dev0/ocstrack/Model/model.py +0 -238
- ocstrack-0.1.3.post1.dev0/ocstrack.egg-info/PKG-INFO +0 -142
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/.github/workflows/publish-to-pypi.yml +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/.github/workflows/run-tests.yml +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/.gitignore +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/.pylintrc +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/LICENSE.txt +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/Collocation/__init__.py +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/Model/__init__.py +0 -0
- {ocstrack-0.1.3.post1.dev0/ocstrack/Satellite → ocstrack-0.1.4.post0/ocstrack/Observation}/__init__.py +0 -0
- {ocstrack-0.1.3.post1.dev0/ocstrack/Satellite → ocstrack-0.1.4.post0/ocstrack/Observation}/satellite.py +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/__init__.py +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack/utils.py +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack.egg-info/dependency_links.txt +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/ocstrack.egg-info/top_level.txt +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/setup.cfg +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/setup.py +0 -0
- {ocstrack-0.1.3.post1.dev0 → ocstrack-0.1.4.post0}/tests/test_get_sat.py +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ocstrack
|
|
3
|
+
Version: 0.1.4.post0
|
|
4
|
+
Summary: Satellite data download, crop, and collocation with model outputs
|
|
5
|
+
Author-email: Felicio Cassalho <felicio.cassalho@noaa.gov>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/noaa-ocs-modeling/OCSTrack
|
|
8
|
+
Project-URL: Repository, https://github.com/noaa-ocs-modeling/OCSTrack
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE.txt
|
|
12
|
+
Requires-Dist: numpy
|
|
13
|
+
Requires-Dist: xarray
|
|
14
|
+
Requires-Dist: scipy
|
|
15
|
+
Requires-Dist: tqdm
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
Requires-Dist: netcdf4
|
|
18
|
+
Requires-Dist: h5netcdf
|
|
19
|
+
Requires-Dist: dask
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pylint; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# OCSTrack
|
|
26
|
+
OCSTrack is an object-oriented Python package for the along-track collocation of satellite (2D) and ArgoFloat (3D) data with ocean circulation and wave model outputs.
|
|
27
|
+
It simplifies the process of aligning diverse datasets, making it easier to compare and analyze satellite observations against model simulations.
|
|
28
|
+
|
|
29
|
+
## Key Features
|
|
30
|
+
### Satellite Altimetry Data Support
|
|
31
|
+
|
|
32
|
+
Seamlessly integrates with NOAA [CoastalWatch](https://coastwatch.noaa.gov/cwn/products/along-track-significant-wave-height-wind-speed-and-sea-level-anomaly-multiple-altimeters.html) altimetry data, providing access to a wide range of missions:
|
|
33
|
+
* Jason-2
|
|
34
|
+
* Jason-3
|
|
35
|
+
* Sentinel-3A
|
|
36
|
+
* Sentinel-3B
|
|
37
|
+
* Sentinel-6A
|
|
38
|
+
* CryoSat-2
|
|
39
|
+
* SARAL
|
|
40
|
+
* SWOT
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Satellite Altimetry Data Support
|
|
44
|
+
|
|
45
|
+
It also integrates the Euro Argo dataset [ifremmer](https://fleetmonitoring.euro-argo.eu/dashboard?Status=Active&Country=France) for 3D temperature and salinity collocation.
|
|
46
|
+
|
|
47
|
+
### Ocean Model Data Support
|
|
48
|
+
Supports outputs from various ocean circulation and wave models:
|
|
49
|
+
* [SCHISM](https://github.com/schism-dev/schism) and its coupled verison with WWMIII
|
|
50
|
+
* [ADCIRC+SWAN](https://adcirc.org/)
|
|
51
|
+
* WaveWatch3 (to be implemented)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
1. **Create new conda environment:**
|
|
57
|
+
This command creates an environment named `ocstrack` and installs all dependencies from `conda-forge`.
|
|
58
|
+
```bash
|
|
59
|
+
conda create -n ocstrack -c conda-forge python=3.10 numpy xarray scipy tqdm requests netcdf4 h5netcdf dask
|
|
60
|
+
conda activate ocstrack
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. **Install `ocstrack`:**
|
|
64
|
+
Finally, install this package using `pip`.
|
|
65
|
+
```bash
|
|
66
|
+
pip install ocstrack
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If you want to install the latest dev version, using this instead:
|
|
70
|
+
```bash
|
|
71
|
+
pip install "git+[https://github.com/noaa-ocs-modeling/OCSTrack.git](https://github.com/noaa-ocs-modeling/OCSTrack.git)"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
See examples directory.
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
We welcome contributions to OCSTrack! If you have ideas for improvements, new features, or find a bug, please don't hesitate to open an issue or submit a pull request on our GitHub repository. Your input helps make OCSTrack better for everyone.
|
|
79
|
+
|
|
80
|
+
### Contact
|
|
81
|
+
<sup>Contact: felicio.cassalho@noaa.gov </sup>
|
|
82
|
+
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
#### Acknowledgements:
|
|
87
|
+
*OCSTrack was inspired by the MATLAB-based [WW3-tools](https://github.com/NOAA-EMC/WW3-tools) and [wave-tools](https://github.com/erdc/wave-tools) collocation tools developed for WaveWatch3.*
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# OCSTrack
|
|
2
|
+
OCSTrack is an object-oriented Python package for the along-track collocation of satellite (2D) and ArgoFloat (3D) data with ocean circulation and wave model outputs.
|
|
3
|
+
It simplifies the process of aligning diverse datasets, making it easier to compare and analyze satellite observations against model simulations.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
### Satellite Altimetry Data Support
|
|
7
|
+
|
|
8
|
+
Seamlessly integrates with NOAA [CoastalWatch](https://coastwatch.noaa.gov/cwn/products/along-track-significant-wave-height-wind-speed-and-sea-level-anomaly-multiple-altimeters.html) altimetry data, providing access to a wide range of missions:
|
|
9
|
+
* Jason-2
|
|
10
|
+
* Jason-3
|
|
11
|
+
* Sentinel-3A
|
|
12
|
+
* Sentinel-3B
|
|
13
|
+
* Sentinel-6A
|
|
14
|
+
* CryoSat-2
|
|
15
|
+
* SARAL
|
|
16
|
+
* SWOT
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Satellite Altimetry Data Support
|
|
20
|
+
|
|
21
|
+
It also integrates the Euro Argo dataset [ifremmer](https://fleetmonitoring.euro-argo.eu/dashboard?Status=Active&Country=France) for 3D temperature and salinity collocation.
|
|
22
|
+
|
|
23
|
+
### Ocean Model Data Support
|
|
24
|
+
Supports outputs from various ocean circulation and wave models:
|
|
25
|
+
* [SCHISM](https://github.com/schism-dev/schism) and its coupled verison with WWMIII
|
|
26
|
+
* [ADCIRC+SWAN](https://adcirc.org/)
|
|
27
|
+
* WaveWatch3 (to be implemented)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
1. **Create new conda environment:**
|
|
33
|
+
This command creates an environment named `ocstrack` and installs all dependencies from `conda-forge`.
|
|
34
|
+
```bash
|
|
35
|
+
conda create -n ocstrack -c conda-forge python=3.10 numpy xarray scipy tqdm requests netcdf4 h5netcdf dask
|
|
36
|
+
conda activate ocstrack
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Install `ocstrack`:**
|
|
40
|
+
Finally, install this package using `pip`.
|
|
41
|
+
```bash
|
|
42
|
+
pip install ocstrack
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If you want to install the latest dev version, using this instead:
|
|
46
|
+
```bash
|
|
47
|
+
pip install "git+[https://github.com/noaa-ocs-modeling/OCSTrack.git](https://github.com/noaa-ocs-modeling/OCSTrack.git)"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
See examples directory.
|
|
52
|
+
|
|
53
|
+
## Contributing
|
|
54
|
+
We welcome contributions to OCSTrack! If you have ideas for improvements, new features, or find a bug, please don't hesitate to open an issue or submit a pull request on our GitHub repository. Your input helps make OCSTrack better for everyone.
|
|
55
|
+
|
|
56
|
+
### Contact
|
|
57
|
+
<sup>Contact: felicio.cassalho@noaa.gov </sup>
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
#### Acknowledgements:
|
|
63
|
+
*OCSTrack was inspired by the MATLAB-based [WW3-tools](https://github.com/NOAA-EMC/WW3-tools) and [wave-tools](https://github.com/erdc/wave-tools) collocation tools developed for WaveWatch3.*
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from ocstrack.Model.model import ADCSWAN
|
|
3
|
+
from ocstrack.Observation.satellite import SatelliteData
|
|
4
|
+
from ocstrack.Observation import get_sat
|
|
5
|
+
from ocstrack.Collocation.collocate import Collocate
|
|
6
|
+
# from ocstrack.utils import convert_longitude
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# 1. Download Satellite Data
|
|
10
|
+
# Specify your desired date range, list of satellites, output directory, and geographical bounding box.
|
|
11
|
+
print("get_sat begin")
|
|
12
|
+
get_sat.get_multi_sat(start_date="2020-12-13",
|
|
13
|
+
end_date="2020-12-31",
|
|
14
|
+
sat_list=['sentinel3a','sentinel3b','jason2','jason3','cryosat2','saral','swot','sentinel6a'],
|
|
15
|
+
output_dir=r"Your/Path/where to save the sat altimetry/Here/",
|
|
16
|
+
lat_min=7,
|
|
17
|
+
lat_max=46,
|
|
18
|
+
lon_min=-98,
|
|
19
|
+
lon_max=-60,
|
|
20
|
+
)
|
|
21
|
+
print("get_sat end")
|
|
22
|
+
|
|
23
|
+
print("load sat begin")
|
|
24
|
+
# 2. Define File Paths
|
|
25
|
+
# Set the paths for your downloaded satellite data, model run, and where you want to save the collocated output.
|
|
26
|
+
sat_path = r"Your/Path/to/Downloaded Satellite Data/Here/",
|
|
27
|
+
model_path = r"Your/Path/to/ADCIRC+SWAN run dir/Here/",
|
|
28
|
+
output_path = r"Your/Path/Here/adcswn_collocated.nc",
|
|
29
|
+
s_time,e_time = "2019-07-30", "2019-08-03"
|
|
30
|
+
|
|
31
|
+
# 3. Load Satellite Data
|
|
32
|
+
# Initialize the SatelliteData object with your satellite data file.
|
|
33
|
+
sat_data = SatelliteData(sat_path)
|
|
34
|
+
# It's crucial to ensure longitude conventions match between satellite and model data.
|
|
35
|
+
# Use convert_longitude if needed (mode=1 for converting to 0-360 degrees).
|
|
36
|
+
# sat_data.lon = convert_longitude(sat_data.lon, mode=1)
|
|
37
|
+
|
|
38
|
+
print("load model begin")
|
|
39
|
+
# 4. Load Model Data
|
|
40
|
+
# Instantiate the SCHISM model object, specifying the run directory and model variable details.
|
|
41
|
+
model_run = ADCSWAN(
|
|
42
|
+
rundir=model_path,
|
|
43
|
+
model_dict={'var': 'swan_HS',
|
|
44
|
+
'startswith': 'swan_HS.63.nc',
|
|
45
|
+
# 'var_type': '2D',
|
|
46
|
+
'model': 'ADCSWAN'},
|
|
47
|
+
start_date=np.datetime64(s_time),
|
|
48
|
+
end_date=np.datetime64(e_time)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
print("Collocation begin")
|
|
52
|
+
# 5. Perform Collocation
|
|
53
|
+
# Create a Collocate object, providing the loaded model and satellite data.A
|
|
54
|
+
# dist_coast = xr.open_dataset(r'Your/Path/to/OPTIONAL/distFromCoast.nc')
|
|
55
|
+
coll = Collocate(
|
|
56
|
+
model_run=model_run,
|
|
57
|
+
observation=sat_data,
|
|
58
|
+
# dist_coast=dist_coast,
|
|
59
|
+
n_nearest=3,
|
|
60
|
+
# search_radius = 3000,
|
|
61
|
+
temporal_interp=True
|
|
62
|
+
)
|
|
63
|
+
ds_coll = coll.run(output_path=output_path) # Execute the collocation and save the results
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"source": [
|
|
35
35
|
"# Slice the file as you wish\n",
|
|
36
36
|
"mask = (\n",
|
|
37
|
-
" (collocated_data[\"
|
|
38
|
-
" (collocated_data[\"
|
|
39
|
-
" (collocated_data[\"dist_coast\"] >= 100) &\n",
|
|
40
|
-
" (collocated_data[\"dist_coast\"] >= 100) &\n",
|
|
37
|
+
" (collocated_data[\"obs_swh\"] <= 7.5) &\n",
|
|
38
|
+
" (collocated_data[\"model_sigWaveHeight_weighted\"] <= 7.5) &\n",
|
|
39
|
+
" # (collocated_data[\"dist_coast\"] >= 100) &\n",
|
|
40
|
+
" # (collocated_data[\"dist_coast\"] >= 100) &\n",
|
|
41
41
|
" (collocated_data[\"model_dpt\"] <=-100).all(dim=\"nearest_nodes\") &\n",
|
|
42
42
|
" # (abs(ds[\"time_deltas\"]) <= 1800) &\n",
|
|
43
43
|
" (collocated_data[\"dist_deltas\"] <= 0.05).all(dim=\"nearest_nodes\") \n",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"outputs": [],
|
|
54
54
|
"source": [
|
|
55
55
|
"# Extract the model and the satellite data\n",
|
|
56
|
-
"x = collocated_data.
|
|
57
|
-
"y = collocated_data.
|
|
56
|
+
"x = collocated_data.obs_swh.values\n",
|
|
57
|
+
"y = collocated_data.model_sigWaveHeight_weighted.values #.model_swh.values.mean(axis=1)\n",
|
|
58
58
|
"xy_max = y.max()"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"cell_type": "code",
|
|
63
|
-
"execution_count":
|
|
63
|
+
"execution_count": null,
|
|
64
64
|
"id": "1a62c4a6-f6dc-495c-aec6-be59496a85a2",
|
|
65
65
|
"metadata": {},
|
|
66
66
|
"outputs": [],
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
" \"vmin\": -5000, \"vmax\": 0,\n",
|
|
85
85
|
" \"cmap\": \"jet\"\n",
|
|
86
86
|
" },\n",
|
|
87
|
-
" {\n",
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
" } \n",
|
|
87
|
+
" # {\n",
|
|
88
|
+
" # \"z\": collocated_data.dist_coast.values,\n",
|
|
89
|
+
" # \"label\": \"Distance from the Coast (km)\",\n",
|
|
90
|
+
" # \"vmin\": 0, \"vmax\": 500,\n",
|
|
91
|
+
" # \"cmap\": \"jet_r\"\n",
|
|
92
|
+
" # } \n",
|
|
93
93
|
"]"
|
|
94
94
|
]
|
|
95
95
|
},
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
],
|
|
123
123
|
"source": [
|
|
124
|
-
"source_cats, source_codes = np.unique(collocated_data.
|
|
124
|
+
"source_cats, source_codes = np.unique(collocated_data.source_obs.values, return_inverse=True)\n",
|
|
125
125
|
"cmap_cat = plt.get_cmap(\"tab10\")\n",
|
|
126
126
|
"\n",
|
|
127
127
|
"norm = mcolors.BoundaryNorm(boundaries=np.arange(-0.5, len(source_cats)+0.5), ncolors=len(source_cats))\n",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from ocstrack.Model.model import SCHISM
|
|
3
|
+
from ocstrack.Observation.satellite import SatelliteData
|
|
4
|
+
from ocstrack.Observation import get_sat
|
|
5
|
+
from ocstrack.Collocation.collocate import Collocate
|
|
6
|
+
from ocstrack.utils import convert_longitude
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# 1. Download Satellite Data
|
|
10
|
+
# Specify your desired date range, list of satellites, output directory, and geographical bounding box.
|
|
11
|
+
print("get_sat begin")
|
|
12
|
+
get_sat.get_multi_sat(start_date="2019-07-30",
|
|
13
|
+
end_date="2019-08-04",
|
|
14
|
+
sat_list=['sentinel3a','sentinel3b','jason2','jason3','cryosat2','saral','swot','sentinel6a'],
|
|
15
|
+
output_dir=r"Your/Path/where to save the sat altimetry/Here/",
|
|
16
|
+
lat_min=50,
|
|
17
|
+
lat_max=59,
|
|
18
|
+
lon_min=165,
|
|
19
|
+
lon_max=-165,
|
|
20
|
+
)
|
|
21
|
+
print("get_sat end")
|
|
22
|
+
|
|
23
|
+
print("load sat begin")
|
|
24
|
+
# 2. Define File Paths
|
|
25
|
+
# Set the paths for your downloaded satellite data, model run, and where you want to save the collocated output.
|
|
26
|
+
sat_path = r"Your/Path/to/Downloaded Satellite Data/Here/",
|
|
27
|
+
model_path = r"Your/Path/to/SCHISM+WWM run dir/Here/",
|
|
28
|
+
output_path = r"Your/Path/Here/schism_collocated.nc",
|
|
29
|
+
s_time,e_time = "2019-07-30", "2019-08-03"
|
|
30
|
+
|
|
31
|
+
# 3. Load Satellite Data
|
|
32
|
+
# Initialize the SatelliteData object with your satellite data file.
|
|
33
|
+
sat_data = SatelliteData(sat_path)
|
|
34
|
+
# It's crucial to ensure longitude conventions match between satellite and model data.
|
|
35
|
+
# Use convert_longitude if needed (mode=1 for converting to 0-360 degrees).
|
|
36
|
+
sat_data.lon = convert_longitude(sat_data.lon, mode=1)
|
|
37
|
+
|
|
38
|
+
print("load model begin")
|
|
39
|
+
# 4. Load Model Data
|
|
40
|
+
# Instantiate the SCHISM model object, specifying the run directory and model variable details.
|
|
41
|
+
model_run = SCHISM(
|
|
42
|
+
rundir=model_path,
|
|
43
|
+
model_dict={'var': 'sigWaveHeight',
|
|
44
|
+
'startswith': 'out2d_', # File name prefix for 2D outputs
|
|
45
|
+
'var_type': '2D',
|
|
46
|
+
'model': 'SCHISM'},
|
|
47
|
+
start_date=np.datetime64(s_time),
|
|
48
|
+
end_date=np.datetime64(e_time)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
print("coll begin")
|
|
52
|
+
|
|
53
|
+
# 5. Perform Collocation
|
|
54
|
+
# Create a Collocate object, providing the loaded model and satellite data.
|
|
55
|
+
# dist_coast = xr.open_dataset(r'Your/Path/to/OPTIONAL/distFromCoast.nc')
|
|
56
|
+
coll = Collocate(
|
|
57
|
+
model_run=model_run,
|
|
58
|
+
observation=sat_data,
|
|
59
|
+
n_nearest=3,
|
|
60
|
+
# search_radius = 3000,
|
|
61
|
+
# dist_coast=dist_coast,
|
|
62
|
+
temporal_interp=True
|
|
63
|
+
)
|
|
64
|
+
ds_coll = coll.run(output_path=output_path) # Execute the collocation and save the results
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from ocstrack.Model.model import SCHISM
|
|
3
|
+
from ocstrack.Observation.argofloat import ArgoData
|
|
4
|
+
from ocstrack.Observation import get_argo
|
|
5
|
+
from ocstrack.Collocation.collocate import Collocate
|
|
6
|
+
from ocstrack.utils import convert_longitude
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Download Argo Data
|
|
10
|
+
# Specify your desired date range, region, output directory, and geographical bounding box.
|
|
11
|
+
print("get_argo begin")
|
|
12
|
+
get_argo.get_argo(start_date="2019-08-29",
|
|
13
|
+
end_date="2019-10-05",
|
|
14
|
+
region = "pacific_ocean",
|
|
15
|
+
output_dir=r"Your/Path/where to save the sat altimetry/Here/",
|
|
16
|
+
lat_min=50,
|
|
17
|
+
lat_max=59,
|
|
18
|
+
lon_min=165,
|
|
19
|
+
lon_max=-165,
|
|
20
|
+
)
|
|
21
|
+
print("get_argo end")
|
|
22
|
+
|
|
23
|
+
print("load argo begin")
|
|
24
|
+
# Define File Paths
|
|
25
|
+
argo_path = r"Your/Path/to/Downloaded/pacific_ocean/processed/"
|
|
26
|
+
model_path = r"Your/Path/to/SCHISM run dir/Here/",
|
|
27
|
+
output_path = r"Your/Path/Here/schism_collocated_argo.nc",
|
|
28
|
+
s_time,e_time = "2019-09-15", "2019-09-30"
|
|
29
|
+
print("load data begin")
|
|
30
|
+
|
|
31
|
+
print("load argo begin")
|
|
32
|
+
argo_data = ArgoData(argo_path)
|
|
33
|
+
print("Argo data loaded.")
|
|
34
|
+
# Use convert_longitude if needed (mode=1 for converting to 0-360 degrees).
|
|
35
|
+
argo_data.lon = convert_longitude(argo_data.lon, mode=1)
|
|
36
|
+
|
|
37
|
+
print("load model begin")
|
|
38
|
+
model_config_3d = {
|
|
39
|
+
'var': 'temperature',
|
|
40
|
+
'startswith': 'temperature_',
|
|
41
|
+
'var_type': '3D_Profile',
|
|
42
|
+
'zcor_var': 'zCoordinates',
|
|
43
|
+
'zcor_startswith': 'zCoordinates_'
|
|
44
|
+
}
|
|
45
|
+
model_run = SCHISM(
|
|
46
|
+
rundir=model_path,
|
|
47
|
+
model_dict=model_config_3d,
|
|
48
|
+
start_date=np.datetime64(s_time),
|
|
49
|
+
end_date=np.datetime64(e_time)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# print("Converting model mesh longitudes...")
|
|
53
|
+
# model_run.mesh_x = convert_longitude(model_run.mesh_x, mode=2)
|
|
54
|
+
# print("Model loaded.")
|
|
55
|
+
|
|
56
|
+
print(f"Argo LONS --- min: {argo_data.lon.min()}, max: {argo_data.lon.max()}")
|
|
57
|
+
print(f"Model LONS --- min: {model_run.mesh_x.min()}, max: {model_run.mesh_x.max()}")
|
|
58
|
+
|
|
59
|
+
print("Initializing Collocate class...")
|
|
60
|
+
# dist_coast = xr.open_dataset(r'Your/Path/to/OPTIONAL/distFromCoast.nc')
|
|
61
|
+
try:
|
|
62
|
+
collocator = Collocate(
|
|
63
|
+
model_run=model_run,
|
|
64
|
+
observation=argo_data,
|
|
65
|
+
# dist_coast=dist_coast,
|
|
66
|
+
n_nearest=3,
|
|
67
|
+
temporal_interp=True
|
|
68
|
+
)
|
|
69
|
+
print("Collocate class initialized.")
|
|
70
|
+
except Exception as e:
|
|
71
|
+
print(f"Error during Collocator initialization: {e}")
|
|
72
|
+
print("Starting collocation run...")
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
collocated_data = collocator.run(output_path=output_path)
|
|
76
|
+
print("Collocation run complete.")
|
|
77
|
+
print(f"Collocation finished. Output saved to: {output_path}")
|
|
78
|
+
print("\n--- Collocated Dataset ---")
|
|
79
|
+
print(collocated_data)
|
|
80
|
+
except Exception as e:
|
|
81
|
+
print(f"Error during collocation run: {e}")
|