goesgcp 2.0.2__tar.gz → 2.0.3__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.
- {goesgcp-2.0.2 → goesgcp-2.0.3}/PKG-INFO +8 -8
- {goesgcp-2.0.2 → goesgcp-2.0.3}/README.md +7 -7
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp/main.py +44 -29
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/PKG-INFO +8 -8
- {goesgcp-2.0.2 → goesgcp-2.0.3}/setup.py +1 -1
- {goesgcp-2.0.2 → goesgcp-2.0.3}/LICENSE +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp/__init__.py +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/SOURCES.txt +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/dependency_links.txt +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/entry_points.txt +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/requires.txt +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/goesgcp.egg-info/top_level.txt +0 -0
- {goesgcp-2.0.2 → goesgcp-2.0.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: goesgcp
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: A package to download and process GOES-16/17 data
|
|
5
5
|
Home-page: https://github.com/helvecioneto/goesgcp
|
|
6
6
|
Author: Helvecio B. L. Neto
|
|
@@ -41,18 +41,18 @@ Dynamic: summary
|
|
|
41
41
|
<!-- badges: end -->
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `
|
|
44
|
+
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `rioxarray` for reprojecting data to EPSG:4326 (rectangular grid), as well cropping it to a user-defined bounding box.
|
|
45
45
|
|
|
46
46
|
## Features
|
|
47
47
|
|
|
48
|
-
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-
|
|
48
|
+
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-18.
|
|
49
49
|
- **Reprojection and cropping**: Reprojects data to EPSG:4326 and crops to a specified bounding box.
|
|
50
50
|
- **Flexible command-line interface**: Customize download options, variables, channels, time range, and output format.
|
|
51
51
|
- **Efficient processing**: Handles large datasets with optimized performance.
|
|
52
52
|
|
|
53
53
|
## Installation
|
|
54
54
|
|
|
55
|
-
Install the
|
|
55
|
+
Install the package via `pip`:
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
pip install goesgcp
|
|
@@ -61,7 +61,7 @@ pip install goesgcp
|
|
|
61
61
|
|
|
62
62
|
## Usage
|
|
63
63
|
|
|
64
|
-
### Command-Line Arguments
|
|
64
|
+
### Available Command-Line Arguments
|
|
65
65
|
|
|
66
66
|
The script uses the `argparse` module for handling command-line arguments. Below are the available options:
|
|
67
67
|
|
|
@@ -97,14 +97,14 @@ A comprehensive list of available GOES products can be found at the following li
|
|
|
97
97
|
In the example below, the command downloads the 3 most recent files from the GOES-16 satellite for the product ABI-L2-CMIPF. It focuses on the variable CMI (Cloud and Moisture Imagery) from channel 13, which is commonly used for infrared observations. The downloaded files are saved to the specified output directory output/.
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --
|
|
100
|
+
goesgcp --satellite goes-16 --recent 3 --product ABI-L2-CMIPF --var_name CMI --channel 13 --output "output/"
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
#### Download Data for a Specific Time Range
|
|
104
|
-
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-
|
|
104
|
+
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-15 12:00:00, focusing on hours 5:00 and 6:00 AM. The data is cropped to the geographic bounds of -35° to 5° latitude and -80° to -30° longitude, reprojected with a resolution of 0.045 degrees, and saved in a by_date format for easy organization.
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-
|
|
107
|
+
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-15 12:00:00' --bt_hour 5 6 --save_format by_date --resolution 0.045 --lat_min -35 --lat_max 5 --lon_min -80 --lon_max -30
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### Contributing
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
<!-- badges: end -->
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `
|
|
10
|
+
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `rioxarray` for reprojecting data to EPSG:4326 (rectangular grid), as well cropping it to a user-defined bounding box.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
|
-
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-
|
|
14
|
+
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-18.
|
|
15
15
|
- **Reprojection and cropping**: Reprojects data to EPSG:4326 and crops to a specified bounding box.
|
|
16
16
|
- **Flexible command-line interface**: Customize download options, variables, channels, time range, and output format.
|
|
17
17
|
- **Efficient processing**: Handles large datasets with optimized performance.
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
21
|
-
Install the
|
|
21
|
+
Install the package via `pip`:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
pip install goesgcp
|
|
@@ -27,7 +27,7 @@ pip install goesgcp
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
-
### Command-Line Arguments
|
|
30
|
+
### Available Command-Line Arguments
|
|
31
31
|
|
|
32
32
|
The script uses the `argparse` module for handling command-line arguments. Below are the available options:
|
|
33
33
|
|
|
@@ -63,14 +63,14 @@ A comprehensive list of available GOES products can be found at the following li
|
|
|
63
63
|
In the example below, the command downloads the 3 most recent files from the GOES-16 satellite for the product ABI-L2-CMIPF. It focuses on the variable CMI (Cloud and Moisture Imagery) from channel 13, which is commonly used for infrared observations. The downloaded files are saved to the specified output directory output/.
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --
|
|
66
|
+
goesgcp --satellite goes-16 --recent 3 --product ABI-L2-CMIPF --var_name CMI --channel 13 --output "output/"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
#### Download Data for a Specific Time Range
|
|
70
|
-
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-
|
|
70
|
+
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-15 12:00:00, focusing on hours 5:00 and 6:00 AM. The data is cropped to the geographic bounds of -35° to 5° latitude and -80° to -30° longitude, reprojected with a resolution of 0.045 degrees, and saved in a by_date format for easy organization.
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-
|
|
73
|
+
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-15 12:00:00' --bt_hour 5 6 --save_format by_date --resolution 0.045 --lat_min -35 --lat_max 5 --lon_min -80 --lon_max -30
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### Contributing
|
|
@@ -34,7 +34,7 @@ def get_directory_prefix(year, julian_day, hour):
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def get_files_period(connection, bucket_name, base_prefix, pattern,
|
|
37
|
-
start, end, bt_hour=[
|
|
37
|
+
start, end, bt_hour=[], bt_min=[], freq=None):
|
|
38
38
|
"""
|
|
39
39
|
Fetches files from a GCP bucket within a specified time period and returns them as a DataFrame.
|
|
40
40
|
|
|
@@ -82,14 +82,14 @@ def get_files_period(connection, bucket_name, base_prefix, pattern,
|
|
|
82
82
|
# Create a DataFrame from the list of files
|
|
83
83
|
df = pd.DataFrame(files_metadata)
|
|
84
84
|
|
|
85
|
+
if df.empty:
|
|
86
|
+
print("No files found matching the pattern and time range.")
|
|
87
|
+
print(prefix)
|
|
88
|
+
sys.exit(1)
|
|
89
|
+
|
|
85
90
|
# Transform file_name to datetime
|
|
86
91
|
df['last_modified'] = pd.to_datetime(df['file_name'].str.extract(r'(\d{4}\d{3}\d{2}\d{2})').squeeze(), format='%Y%j%H%M')
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
if df.empty:
|
|
90
|
-
print("No files found matching the pattern.")
|
|
91
|
-
return pd.DataFrame()
|
|
92
|
-
|
|
93
93
|
# Ensure 'last_modified' is in the correct datetime format without timezone
|
|
94
94
|
df['last_modified'] = pd.to_datetime(df['last_modified']).dt.tz_localize('UTC')
|
|
95
95
|
|
|
@@ -97,16 +97,19 @@ def get_files_period(connection, bucket_name, base_prefix, pattern,
|
|
|
97
97
|
df = df[(df['last_modified'] >= start) & (df['last_modified'] <= end)]
|
|
98
98
|
|
|
99
99
|
# Filter the DataFrame based on the hour range
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
if len(bt_hour) > 1:
|
|
101
|
+
df['hour'] = df['last_modified'].dt.hour
|
|
102
|
+
df = df[(df['hour'] >= bt_hour[0]) & (df['hour'] <= bt_hour[1])]
|
|
102
103
|
|
|
103
104
|
# Filter the DataFrame based on the minute range
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
if len(bt_min) > 1:
|
|
106
|
+
df['minute'] = df['last_modified'].dt.minute
|
|
107
|
+
df = df[(df['minute'] >= bt_min[0]) & (df['minute'] <= bt_min[1])]
|
|
106
108
|
|
|
107
109
|
# Filter the DataFrame based on the frequency
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
if freq is not None:
|
|
111
|
+
df['freq'] = df['last_modified'].dt.floor(freq)
|
|
112
|
+
df = df.groupby('freq').first().reset_index()
|
|
110
113
|
|
|
111
114
|
return df['file_name'].tolist()
|
|
112
115
|
|
|
@@ -139,7 +142,7 @@ def get_recent_files(connection, bucket_name, base_prefix, pattern, min_files):
|
|
|
139
142
|
|
|
140
143
|
# Filter blobs based on the pattern
|
|
141
144
|
for blob in blobs:
|
|
142
|
-
if pattern in blob.name:
|
|
145
|
+
if pattern in blob.name:
|
|
143
146
|
files.append((blob.name, blob.updated))
|
|
144
147
|
|
|
145
148
|
# Go back one hour
|
|
@@ -221,23 +224,27 @@ def crop_reproject(args):
|
|
|
221
224
|
except:
|
|
222
225
|
pass
|
|
223
226
|
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
try:
|
|
228
|
+
# Reproject to EPSG:4326
|
|
229
|
+
ds = ds.rio.reproject("EPSG:4326", resolution=resolution)
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
# Rename lat/lon coordinates
|
|
232
|
+
ds = ds.rename({"x": "lon", "y": "lat"})
|
|
229
233
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
# Add resolution to attributes
|
|
235
|
+
for var in var_names:
|
|
236
|
+
ds[var].attrs['resolution'] = "x={:.2f} y={:.2f} degree".format(resolution, resolution)
|
|
237
|
+
ds[var].attrs['comments'] = 'Cropped and reprojected to EPSG:4326 by goesgcp'
|
|
234
238
|
|
|
235
|
-
|
|
236
|
-
|
|
239
|
+
# Crop using lat/lon coordinates, in parallel
|
|
240
|
+
ds = ds.rio.clip_box(minx=lon_min, miny=lat_min, maxx=lon_max, maxy=lat_max)
|
|
237
241
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
# Add global metadata comments
|
|
243
|
+
ds.attrs['comments'] = "Data processed by goesgcp, author: Helvecio B. L. Neto (helvecioblneto@gmail.com)"
|
|
244
|
+
except Exception as e:
|
|
245
|
+
print(f"Error processing file {file}: {e}")
|
|
246
|
+
pass
|
|
247
|
+
|
|
241
248
|
if save_format == 'by_date':
|
|
242
249
|
file_datetime = datetime.strptime(ds.time_coverage_start,
|
|
243
250
|
"%Y-%m-%dT%H:%M:%S.%fZ")
|
|
@@ -253,13 +260,14 @@ def crop_reproject(args):
|
|
|
253
260
|
output_directory = f"{output}{year}/{julian_day}/"
|
|
254
261
|
else:
|
|
255
262
|
output_directory = output
|
|
263
|
+
|
|
256
264
|
|
|
257
265
|
# Create the output directory
|
|
258
266
|
pathlib.Path(output_directory).mkdir(parents=True, exist_ok=True)
|
|
259
267
|
|
|
260
268
|
# Save the file
|
|
261
269
|
output_file = f"{output_directory}{file.split('/')[-1]}"
|
|
262
|
-
ds.to_netcdf(output_file, mode='w'
|
|
270
|
+
ds.to_netcdf(output_file, mode='w')
|
|
263
271
|
|
|
264
272
|
ds.close()
|
|
265
273
|
|
|
@@ -345,7 +353,7 @@ def main():
|
|
|
345
353
|
parser.add_argument('--product', type=str, default='ABI-L2-CMIPF', help='Name of the satellite product', choices=product_names)
|
|
346
354
|
parser.add_argument('--var_name', type=str, default=None, help='Variable name to extract (e.g., CMI)')
|
|
347
355
|
parser.add_argument('--channel', type=int, default=13, help='Channel to use (e.g., 13)')
|
|
348
|
-
parser.add_argument('--op_mode', type=str, default='
|
|
356
|
+
parser.add_argument('--op_mode', type=str, default='M6', help='Operational mode to use (e.g., M6C)')
|
|
349
357
|
|
|
350
358
|
# Recent files settings
|
|
351
359
|
parser.add_argument('--recent', type=int, help='Number of recent files to download (e.g., 3)')
|
|
@@ -385,7 +393,7 @@ def main():
|
|
|
385
393
|
satellite = args.satellite
|
|
386
394
|
product = args.product
|
|
387
395
|
op_mode = args.op_mode
|
|
388
|
-
channel =
|
|
396
|
+
channel = args.channel
|
|
389
397
|
var_name = args.var_name
|
|
390
398
|
lat_min = args.lat_min
|
|
391
399
|
lat_max = args.lat_max
|
|
@@ -421,6 +429,13 @@ def main():
|
|
|
421
429
|
print(f"Bucket {bucket_name} not found. Exiting...")
|
|
422
430
|
sys.exit(1)
|
|
423
431
|
|
|
432
|
+
# Check if the channel exists
|
|
433
|
+
if not channel:
|
|
434
|
+
channel = ''
|
|
435
|
+
else:
|
|
436
|
+
channel = str(channel).zfill(2)
|
|
437
|
+
channel = f"C{channel}"
|
|
438
|
+
|
|
424
439
|
# Set pattern for the files
|
|
425
440
|
pattern = "OR_"+product+"-"+op_mode+channel+"_G" + satellite[-2:]
|
|
426
441
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: goesgcp
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: A package to download and process GOES-16/17 data
|
|
5
5
|
Home-page: https://github.com/helvecioneto/goesgcp
|
|
6
6
|
Author: Helvecio B. L. Neto
|
|
@@ -41,18 +41,18 @@ Dynamic: summary
|
|
|
41
41
|
<!-- badges: end -->
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `
|
|
44
|
+
`goesgcp` is a Python utility designed for downloading and reprojecting GOES-R satellite data. This script leverages the `google.cloud` library for accessing data from the Google Cloud Platform (GCP) and `rioxarray` for reprojecting data to EPSG:4326 (rectangular grid), as well cropping it to a user-defined bounding box.
|
|
45
45
|
|
|
46
46
|
## Features
|
|
47
47
|
|
|
48
|
-
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-
|
|
48
|
+
- **Download GOES-R satellite data**: Supports GOES-16 and GOES-18.
|
|
49
49
|
- **Reprojection and cropping**: Reprojects data to EPSG:4326 and crops to a specified bounding box.
|
|
50
50
|
- **Flexible command-line interface**: Customize download options, variables, channels, time range, and output format.
|
|
51
51
|
- **Efficient processing**: Handles large datasets with optimized performance.
|
|
52
52
|
|
|
53
53
|
## Installation
|
|
54
54
|
|
|
55
|
-
Install the
|
|
55
|
+
Install the package via `pip`:
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
pip install goesgcp
|
|
@@ -61,7 +61,7 @@ pip install goesgcp
|
|
|
61
61
|
|
|
62
62
|
## Usage
|
|
63
63
|
|
|
64
|
-
### Command-Line Arguments
|
|
64
|
+
### Available Command-Line Arguments
|
|
65
65
|
|
|
66
66
|
The script uses the `argparse` module for handling command-line arguments. Below are the available options:
|
|
67
67
|
|
|
@@ -97,14 +97,14 @@ A comprehensive list of available GOES products can be found at the following li
|
|
|
97
97
|
In the example below, the command downloads the 3 most recent files from the GOES-16 satellite for the product ABI-L2-CMIPF. It focuses on the variable CMI (Cloud and Moisture Imagery) from channel 13, which is commonly used for infrared observations. The downloaded files are saved to the specified output directory output/.
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --
|
|
100
|
+
goesgcp --satellite goes-16 --recent 3 --product ABI-L2-CMIPF --var_name CMI --channel 13 --output "output/"
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
#### Download Data for a Specific Time Range
|
|
104
|
-
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-
|
|
104
|
+
This command retrieves GOES-16 satellite data for the product ABI-L2-CMIPF within the date range 2022-12-15 00:00:00 to 2022-12-15 12:00:00, focusing on hours 5:00 and 6:00 AM. The data is cropped to the geographic bounds of -35° to 5° latitude and -80° to -30° longitude, reprojected with a resolution of 0.045 degrees, and saved in a by_date format for easy organization.
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-
|
|
107
|
+
goesgcp --satellite goes-16 --product ABI-L2-CMIPF --start '2022-12-15 00:00:00' --end '2022-12-15 12:00:00' --bt_hour 5 6 --save_format by_date --resolution 0.045 --lat_min -35 --lat_max 5 --lon_min -80 --lon_max -30
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### Contributing
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|