Skip to content

HmbGen

HmbGen

A high-level interface intended to simplify the usage of the package for common scenarios. This uses other API elements that can also be used directly for more control on the settings or more advanced scenarios.

Here is a basic, schematic example of how to use this class:

# Create instance:
hmb_gen = HmbGen()

# Indicate parameters as needed:
hmb_gen.set_json_base_dir("json")
hmb_gen.set_global_attrs_uri("gs://bucket/globalAttributes.yaml")
hmb_gen.set_variable_attrs_uri("gs://bucket/variableAttributes.yaml")
hmb_gen.set_subset_to((0, 100))
hmb_gen.set_download_dir("download")
hmb_gen.set_output_dir("output")
hmb_gen.set_output_prefix("hmb_")
hmb_gen.set_add_quality_flag(True)
hmb_gen.set_gs_client(gs_client)

# Before processing, perform basic check of the parameters:
errors = hmb_gen.check_parameters()
if errors:
    print(f"Errors: {errors}")
else:
    result = hmb_gen.process_date("20220101")
    if result:
        print(f"Result: {result}")
    hmb_gen.plot_date(
        "20220101",
        lat_lon_for_solpos=(37.7749, -122.4194),
        title="HMB",
        ylim=(0, 100),
        cmlim=(0, 100),
        dpi=300,
        show=True,
    )

Source code in pbp/simpleapi.py
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
class HmbGen:
    """
    A high-level interface intended to simplify the usage of the package for common scenarios.
    This uses other API elements that can also be used directly for more control on the
    settings or more advanced scenarios.

    Here is a basic, schematic example of how to use this class:
    ```python
    # Create instance:
    hmb_gen = HmbGen()

    # Indicate parameters as needed:
    hmb_gen.set_json_base_dir("json")
    hmb_gen.set_global_attrs_uri("gs://bucket/globalAttributes.yaml")
    hmb_gen.set_variable_attrs_uri("gs://bucket/variableAttributes.yaml")
    hmb_gen.set_subset_to((0, 100))
    hmb_gen.set_download_dir("download")
    hmb_gen.set_output_dir("output")
    hmb_gen.set_output_prefix("hmb_")
    hmb_gen.set_add_quality_flag(True)
    hmb_gen.set_gs_client(gs_client)

    # Before processing, perform basic check of the parameters:
    errors = hmb_gen.check_parameters()
    if errors:
        print(f"Errors: {errors}")
    else:
        result = hmb_gen.process_date("20220101")
        if result:
            print(f"Result: {result}")
        hmb_gen.plot_date(
            "20220101",
            lat_lon_for_solpos=(37.7749, -122.4194),
            title="HMB",
            ylim=(0, 100),
            cmlim=(0, 100),
            dpi=300,
            show=True,
        )
    ```
    """

    def __init__(self) -> None:
        """
        Create a new object for HMB generation.
        On the created instance, call the various `set_*` methods to set the parameters,
        `check_parameters()` to verify the parameters, and
        then call `process_date()` to execute the process for a given date.

        See source code for more details on the default parameter values.
        """
        self._json_base_dir: str = ""
        self._global_attrs_uri: str = ""
        self._variable_attrs_uri: str = ""
        self._voltage_multiplier: float = 1.0
        self._sensitivity: float | str = 1.0
        self._subset_to: Optional[tuple[int, int]] = None
        self._download_dir: str = ""
        self._output_dir: str = ""
        self._output_prefix: str = ""
        self._compress_netcdf: bool = True
        self._add_quality_flag: bool = False

        self._assume_downloaded_files: bool = False
        self._retain_downloaded_files: bool = False
        self._print_downloading_lines: bool = False

        # Other attributes
        self._s3_client: Optional[BaseClient] = None
        self._gs_client: Optional[GsClient] = None

        self._hmb_gen: Optional[_HmbGen] = None

    def set_json_base_dir(self, json_base_dir: str) -> None:
        """
        Set the base directory where JSON files are located.

        Args:
            json_base_dir (str): The base directory where JSON files are located.
        """
        self._json_base_dir = json_base_dir

    def set_global_attrs_uri(self, global_attrs_uri: str) -> None:
        """
        Set the URI for global attributes.

        Args:
            global_attrs_uri (str): The URI for global attributes.
        """
        self._global_attrs_uri = global_attrs_uri

    def set_variable_attrs_uri(self, variable_attrs_uri: str) -> None:
        """
        Set the URI for variable attributes.

        Args:
            variable_attrs_uri (str): The URI for variable attributes.
        """
        self._variable_attrs_uri = variable_attrs_uri

    def set_voltage_multiplier(self, voltage_multiplier: float) -> None:
        """
        Set the voltage multiplier. By default, this is 1.0.

        Args:
            voltage_multiplier (float): The voltage multiplier.
        """
        self._voltage_multiplier = voltage_multiplier

    def set_sensitivity(self, sensitivity: float | str) -> None:
        """
        Set Sensitivity flat value (a float), or URI of sensitivity file.

        Args:
            sensitivity (float | str): Sensitivity flat value (a float), or URI of sensitivity file.
        """
        self._sensitivity = sensitivity

    def set_subset_to(self, subset_to: tuple[int, int]) -> None:
        """
        Set the frequency subset to use for the PSD.

        Args:
            subset_to (tuple[int, int]): Tuple of (lower, upper), with lower inclusive, upper exclusive.
        """
        self._subset_to = subset_to

    def set_download_dir(self, download_dir: str) -> None:
        """
        Set the download directory.

        Args:
            download_dir (str): The download directory.
        """
        self._download_dir = download_dir

    def set_output_dir(self, output_dir: str) -> None:
        """
        Set the output directory.

        Args:
            output_dir (str): The output directory.
        """
        self._output_dir = output_dir

    def set_output_prefix(self, output_prefix: str) -> None:
        """
        Set the output prefix.

        Args:
            output_prefix (str): The output prefix.
        """
        self._output_prefix = output_prefix

    def set_compress_netcdf(self, compress_netcdf: bool) -> None:
        """
        Set whether to compress the NetCDF file.
        This is done by default.

        Args:
            compress_netcdf (bool): Whether to compress the NetCDF file.
        """
        self._compress_netcdf = compress_netcdf

    def set_add_quality_flag(self, add_quality_flag: bool) -> None:
        """
        Set whether to add quality flag variable (with value fixed to 2 - "Not evaluated") to the NetCDF file.
        This is not done by default.

        Args:
            add_quality_flag (bool): Whether to add quality flag variable.
        """
        self._add_quality_flag = add_quality_flag

    def set_assume_downloaded_files(self, value: bool) -> None:
        """
        Set whether to skip downloading files that already exist in the download directory.
        This is not done by default.

        Args:
            value:
                If True, skip downloading files that already exist in the download directory.
        """
        self._assume_downloaded_files = value

    def set_retain_downloaded_files(self, value: bool) -> None:
        """
        Set whether to retain downloaded files after use.
        This is not done by default.

        Args:
            value:
                If True, do not remove downloaded files after use.
        """
        self._retain_downloaded_files = value

    def set_print_downloading_lines(self, value: bool) -> None:
        """
        Set whether to print "downloading <uri>" lines to console.
        This is not done by default.

        Args:
            value:
                If True, print "downloading <uri>" lines to console.
        """
        self._print_downloading_lines = value

    def set_s3_client(self, s3_client: BaseClient) -> None:
        """
        Set the S3 client.

        Args:
            s3_client (BaseClient): The S3 client.
        """
        if self._gs_client:
            raise ValueError("A GS client has already been set.")
        self._s3_client = s3_client

    def set_gs_client(self, gs_client: GsClient) -> None:
        """
        Set the GS client.

        Args:
            gs_client (GsClient): The GS client.
        """
        if self._s3_client:
            raise ValueError("A S3 client has already been set.")
        self._gs_client = gs_client

    def check_parameters(self) -> str | None:
        """
        Performs a basic check of the parameters,
        especially verifying that the required ones are given.
        Call this before performing any processing.

        Returns:
            None if no errors, otherwise a string with the errors.
        """
        errors = []

        if not self._json_base_dir:
            errors.append("- json_base_dir not set")

        if not self._global_attrs_uri:
            errors.append("- global_attrs_uri not set")

        if not self._variable_attrs_uri:
            errors.append("- variable_attrs_uri not set")

        if not self._download_dir:
            errors.append("- download_dir not set")

        if not self._output_dir:
            errors.append("- output_dir not set")

        if not self._subset_to:
            errors.append("- subset_to not set")

        if not self._sensitivity:
            errors.append("- sensitivity not set.")
        elif not isinstance(self._sensitivity, (float, int, str)):
            errors.append("- sensitivity must be a number or a string")

        if not isinstance(self._subset_to, tuple):
            errors.append("- subset_to must be a tuple")
        else:
            if len(list(self._subset_to)) != 2:
                errors.append("- subset_to must be a tuple of length 2")
            if not isinstance(self._subset_to[0], int) or not isinstance(
                self._subset_to[1], int
            ):
                errors.append("- subset_to must contain integers")

        if not self._s3_client and not self._gs_client:
            errors.append("- No S3 or GS client has been set")

        if len(errors) > 0:
            return "\n".join(errors)

        # make mypy happy
        assert isinstance(self._subset_to, tuple)

        self._hmb_gen = _HmbGen(
            json_base_dir=self._json_base_dir,
            global_attrs_uri=self._global_attrs_uri,
            variable_attrs_uri=self._variable_attrs_uri,
            voltage_multiplier=self._voltage_multiplier,
            sensitivity=self._sensitivity,
            subset_to=self._subset_to,
            download_dir=self._download_dir,
            output_dir=self._output_dir,
            output_prefix=self._output_prefix,
            compress_netcdf=self._compress_netcdf,
            add_quality_flag=self._add_quality_flag,
            assume_downloaded_files=self._assume_downloaded_files,
            retain_downloaded_files=self._retain_downloaded_files,
            print_downloading_lines=self._print_downloading_lines,
            s3_client=self._s3_client,
            gs_client=self._gs_client,
        )
        return None

    def process_date(self, date: str) -> ProcessDayResult | str:
        """
        Generates NetCDF file with the result of processing all segments of the given day.

        Args:
            date (str): Date to process in YYYYMMDD format.

        Returns:
            ProcessDayResult if segments were processed, otherwise a string with an error.
        """
        if not self._hmb_gen:
            return "Missing or invalid parameters. Call check_parameters() first."

        result = self._hmb_gen.process_date(date)
        return result or f"No segments processed for {date}."

    def plot_date(
        self,
        date: str,
        lat_lon_for_solpos: tuple[float, float],
        title: str,
        ylim: tuple[int, int],
        cmlim: tuple[int, int],
        dpi: int,
        show: bool = False,
    ) -> None:
        """
        Generate a summary plot for the given date.
        Make sure the NetCDF file for the given date has been generated first.
        The output will be saved as a JPEG file with name derived from the input date
        resulting in a sibling file to the NetCDF file.

        Args:
            date (str): Date to plot in `YYYYMMDD` format.
            lat_lon_for_solpos (tuple[float, float]): Latitude and longitude for solar position calculation.
            title (str, optional): Title for the plot.
            ylim (tuple[float, float], optional): Limits for the y-axis.
            cmlim (tuple[float, float], optional): Limits passed to `pcolormesh`.
            dpi (int, optional): DPI to use for the plot.
            show (bool, optional): Whether to also show the plot. Defaults to `False`, meaning only the JPEG file is generated.
        """
        if not self._hmb_gen:
            raise ValueError(
                "Missing or invalid parameters. Call check_parameters() first."
            )

        return self._hmb_gen.plot_date(
            date,
            lat_lon_for_solpos,
            title,
            ylim,
            cmlim,
            dpi,
            show,
        )

__init__()

Create a new object for HMB generation. On the created instance, call the various set_* methods to set the parameters, check_parameters() to verify the parameters, and then call process_date() to execute the process for a given date.

See source code for more details on the default parameter values.

Source code in pbp/simpleapi.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(self) -> None:
    """
    Create a new object for HMB generation.
    On the created instance, call the various `set_*` methods to set the parameters,
    `check_parameters()` to verify the parameters, and
    then call `process_date()` to execute the process for a given date.

    See source code for more details on the default parameter values.
    """
    self._json_base_dir: str = ""
    self._global_attrs_uri: str = ""
    self._variable_attrs_uri: str = ""
    self._voltage_multiplier: float = 1.0
    self._sensitivity: float | str = 1.0
    self._subset_to: Optional[tuple[int, int]] = None
    self._download_dir: str = ""
    self._output_dir: str = ""
    self._output_prefix: str = ""
    self._compress_netcdf: bool = True
    self._add_quality_flag: bool = False

    self._assume_downloaded_files: bool = False
    self._retain_downloaded_files: bool = False
    self._print_downloading_lines: bool = False

    # Other attributes
    self._s3_client: Optional[BaseClient] = None
    self._gs_client: Optional[GsClient] = None

    self._hmb_gen: Optional[_HmbGen] = None

set_json_base_dir(json_base_dir)

Set the base directory where JSON files are located.

Parameters:

Name Type Description Default
json_base_dir str

The base directory where JSON files are located.

required
Source code in pbp/simpleapi.py
89
90
91
92
93
94
95
96
def set_json_base_dir(self, json_base_dir: str) -> None:
    """
    Set the base directory where JSON files are located.

    Args:
        json_base_dir (str): The base directory where JSON files are located.
    """
    self._json_base_dir = json_base_dir

set_global_attrs_uri(global_attrs_uri)

Set the URI for global attributes.

Parameters:

Name Type Description Default
global_attrs_uri str

The URI for global attributes.

required
Source code in pbp/simpleapi.py
 98
 99
100
101
102
103
104
105
def set_global_attrs_uri(self, global_attrs_uri: str) -> None:
    """
    Set the URI for global attributes.

    Args:
        global_attrs_uri (str): The URI for global attributes.
    """
    self._global_attrs_uri = global_attrs_uri

set_variable_attrs_uri(variable_attrs_uri)

Set the URI for variable attributes.

Parameters:

Name Type Description Default
variable_attrs_uri str

The URI for variable attributes.

required
Source code in pbp/simpleapi.py
107
108
109
110
111
112
113
114
def set_variable_attrs_uri(self, variable_attrs_uri: str) -> None:
    """
    Set the URI for variable attributes.

    Args:
        variable_attrs_uri (str): The URI for variable attributes.
    """
    self._variable_attrs_uri = variable_attrs_uri

set_voltage_multiplier(voltage_multiplier)

Set the voltage multiplier. By default, this is 1.0.

Parameters:

Name Type Description Default
voltage_multiplier float

The voltage multiplier.

required
Source code in pbp/simpleapi.py
116
117
118
119
120
121
122
123
def set_voltage_multiplier(self, voltage_multiplier: float) -> None:
    """
    Set the voltage multiplier. By default, this is 1.0.

    Args:
        voltage_multiplier (float): The voltage multiplier.
    """
    self._voltage_multiplier = voltage_multiplier

set_sensitivity(sensitivity)

Set Sensitivity flat value (a float), or URI of sensitivity file.

Parameters:

Name Type Description Default
sensitivity float | str

Sensitivity flat value (a float), or URI of sensitivity file.

required
Source code in pbp/simpleapi.py
125
126
127
128
129
130
131
132
def set_sensitivity(self, sensitivity: float | str) -> None:
    """
    Set Sensitivity flat value (a float), or URI of sensitivity file.

    Args:
        sensitivity (float | str): Sensitivity flat value (a float), or URI of sensitivity file.
    """
    self._sensitivity = sensitivity

set_subset_to(subset_to)

Set the frequency subset to use for the PSD.

Parameters:

Name Type Description Default
subset_to tuple[int, int]

Tuple of (lower, upper), with lower inclusive, upper exclusive.

required
Source code in pbp/simpleapi.py
134
135
136
137
138
139
140
141
def set_subset_to(self, subset_to: tuple[int, int]) -> None:
    """
    Set the frequency subset to use for the PSD.

    Args:
        subset_to (tuple[int, int]): Tuple of (lower, upper), with lower inclusive, upper exclusive.
    """
    self._subset_to = subset_to

set_download_dir(download_dir)

Set the download directory.

Parameters:

Name Type Description Default
download_dir str

The download directory.

required
Source code in pbp/simpleapi.py
143
144
145
146
147
148
149
150
def set_download_dir(self, download_dir: str) -> None:
    """
    Set the download directory.

    Args:
        download_dir (str): The download directory.
    """
    self._download_dir = download_dir

set_output_dir(output_dir)

Set the output directory.

Parameters:

Name Type Description Default
output_dir str

The output directory.

required
Source code in pbp/simpleapi.py
152
153
154
155
156
157
158
159
def set_output_dir(self, output_dir: str) -> None:
    """
    Set the output directory.

    Args:
        output_dir (str): The output directory.
    """
    self._output_dir = output_dir

set_output_prefix(output_prefix)

Set the output prefix.

Parameters:

Name Type Description Default
output_prefix str

The output prefix.

required
Source code in pbp/simpleapi.py
161
162
163
164
165
166
167
168
def set_output_prefix(self, output_prefix: str) -> None:
    """
    Set the output prefix.

    Args:
        output_prefix (str): The output prefix.
    """
    self._output_prefix = output_prefix

set_compress_netcdf(compress_netcdf)

Set whether to compress the NetCDF file. This is done by default.

Parameters:

Name Type Description Default
compress_netcdf bool

Whether to compress the NetCDF file.

required
Source code in pbp/simpleapi.py
170
171
172
173
174
175
176
177
178
def set_compress_netcdf(self, compress_netcdf: bool) -> None:
    """
    Set whether to compress the NetCDF file.
    This is done by default.

    Args:
        compress_netcdf (bool): Whether to compress the NetCDF file.
    """
    self._compress_netcdf = compress_netcdf

set_add_quality_flag(add_quality_flag)

Set whether to add quality flag variable (with value fixed to 2 - "Not evaluated") to the NetCDF file. This is not done by default.

Parameters:

Name Type Description Default
add_quality_flag bool

Whether to add quality flag variable.

required
Source code in pbp/simpleapi.py
180
181
182
183
184
185
186
187
188
def set_add_quality_flag(self, add_quality_flag: bool) -> None:
    """
    Set whether to add quality flag variable (with value fixed to 2 - "Not evaluated") to the NetCDF file.
    This is not done by default.

    Args:
        add_quality_flag (bool): Whether to add quality flag variable.
    """
    self._add_quality_flag = add_quality_flag

set_assume_downloaded_files(value)

Set whether to skip downloading files that already exist in the download directory. This is not done by default.

Parameters:

Name Type Description Default
value bool

If True, skip downloading files that already exist in the download directory.

required
Source code in pbp/simpleapi.py
190
191
192
193
194
195
196
197
198
199
def set_assume_downloaded_files(self, value: bool) -> None:
    """
    Set whether to skip downloading files that already exist in the download directory.
    This is not done by default.

    Args:
        value:
            If True, skip downloading files that already exist in the download directory.
    """
    self._assume_downloaded_files = value

set_retain_downloaded_files(value)

Set whether to retain downloaded files after use. This is not done by default.

Parameters:

Name Type Description Default
value bool

If True, do not remove downloaded files after use.

required
Source code in pbp/simpleapi.py
201
202
203
204
205
206
207
208
209
210
def set_retain_downloaded_files(self, value: bool) -> None:
    """
    Set whether to retain downloaded files after use.
    This is not done by default.

    Args:
        value:
            If True, do not remove downloaded files after use.
    """
    self._retain_downloaded_files = value

set_print_downloading_lines(value)

Set whether to print "downloading " lines to console. This is not done by default.

Parameters:

Name Type Description Default
value bool

If True, print "downloading " lines to console.

required
Source code in pbp/simpleapi.py
212
213
214
215
216
217
218
219
220
221
def set_print_downloading_lines(self, value: bool) -> None:
    """
    Set whether to print "downloading <uri>" lines to console.
    This is not done by default.

    Args:
        value:
            If True, print "downloading <uri>" lines to console.
    """
    self._print_downloading_lines = value

set_s3_client(s3_client)

Set the S3 client.

Parameters:

Name Type Description Default
s3_client BaseClient

The S3 client.

required
Source code in pbp/simpleapi.py
223
224
225
226
227
228
229
230
231
232
def set_s3_client(self, s3_client: BaseClient) -> None:
    """
    Set the S3 client.

    Args:
        s3_client (BaseClient): The S3 client.
    """
    if self._gs_client:
        raise ValueError("A GS client has already been set.")
    self._s3_client = s3_client

set_gs_client(gs_client)

Set the GS client.

Parameters:

Name Type Description Default
gs_client Client

The GS client.

required
Source code in pbp/simpleapi.py
234
235
236
237
238
239
240
241
242
243
def set_gs_client(self, gs_client: GsClient) -> None:
    """
    Set the GS client.

    Args:
        gs_client (GsClient): The GS client.
    """
    if self._s3_client:
        raise ValueError("A S3 client has already been set.")
    self._gs_client = gs_client

check_parameters()

Performs a basic check of the parameters, especially verifying that the required ones are given. Call this before performing any processing.

Returns:

Type Description
str | None

None if no errors, otherwise a string with the errors.

Source code in pbp/simpleapi.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
def check_parameters(self) -> str | None:
    """
    Performs a basic check of the parameters,
    especially verifying that the required ones are given.
    Call this before performing any processing.

    Returns:
        None if no errors, otherwise a string with the errors.
    """
    errors = []

    if not self._json_base_dir:
        errors.append("- json_base_dir not set")

    if not self._global_attrs_uri:
        errors.append("- global_attrs_uri not set")

    if not self._variable_attrs_uri:
        errors.append("- variable_attrs_uri not set")

    if not self._download_dir:
        errors.append("- download_dir not set")

    if not self._output_dir:
        errors.append("- output_dir not set")

    if not self._subset_to:
        errors.append("- subset_to not set")

    if not self._sensitivity:
        errors.append("- sensitivity not set.")
    elif not isinstance(self._sensitivity, (float, int, str)):
        errors.append("- sensitivity must be a number or a string")

    if not isinstance(self._subset_to, tuple):
        errors.append("- subset_to must be a tuple")
    else:
        if len(list(self._subset_to)) != 2:
            errors.append("- subset_to must be a tuple of length 2")
        if not isinstance(self._subset_to[0], int) or not isinstance(
            self._subset_to[1], int
        ):
            errors.append("- subset_to must contain integers")

    if not self._s3_client and not self._gs_client:
        errors.append("- No S3 or GS client has been set")

    if len(errors) > 0:
        return "\n".join(errors)

    # make mypy happy
    assert isinstance(self._subset_to, tuple)

    self._hmb_gen = _HmbGen(
        json_base_dir=self._json_base_dir,
        global_attrs_uri=self._global_attrs_uri,
        variable_attrs_uri=self._variable_attrs_uri,
        voltage_multiplier=self._voltage_multiplier,
        sensitivity=self._sensitivity,
        subset_to=self._subset_to,
        download_dir=self._download_dir,
        output_dir=self._output_dir,
        output_prefix=self._output_prefix,
        compress_netcdf=self._compress_netcdf,
        add_quality_flag=self._add_quality_flag,
        assume_downloaded_files=self._assume_downloaded_files,
        retain_downloaded_files=self._retain_downloaded_files,
        print_downloading_lines=self._print_downloading_lines,
        s3_client=self._s3_client,
        gs_client=self._gs_client,
    )
    return None

process_date(date)

Generates NetCDF file with the result of processing all segments of the given day.

Parameters:

Name Type Description Default
date str

Date to process in YYYYMMDD format.

required

Returns:

Type Description
ProcessDayResult | str

ProcessDayResult if segments were processed, otherwise a string with an error.

Source code in pbp/simpleapi.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
def process_date(self, date: str) -> ProcessDayResult | str:
    """
    Generates NetCDF file with the result of processing all segments of the given day.

    Args:
        date (str): Date to process in YYYYMMDD format.

    Returns:
        ProcessDayResult if segments were processed, otherwise a string with an error.
    """
    if not self._hmb_gen:
        return "Missing or invalid parameters. Call check_parameters() first."

    result = self._hmb_gen.process_date(date)
    return result or f"No segments processed for {date}."

plot_date(date, lat_lon_for_solpos, title, ylim, cmlim, dpi, show=False)

Generate a summary plot for the given date. Make sure the NetCDF file for the given date has been generated first. The output will be saved as a JPEG file with name derived from the input date resulting in a sibling file to the NetCDF file.

Parameters:

Name Type Description Default
date str

Date to plot in YYYYMMDD format.

required
lat_lon_for_solpos tuple[float, float]

Latitude and longitude for solar position calculation.

required
title str

Title for the plot.

required
ylim tuple[float, float]

Limits for the y-axis.

required
cmlim tuple[float, float]

Limits passed to pcolormesh.

required
dpi int

DPI to use for the plot.

required
show bool

Whether to also show the plot. Defaults to False, meaning only the JPEG file is generated.

False
Source code in pbp/simpleapi.py
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
def plot_date(
    self,
    date: str,
    lat_lon_for_solpos: tuple[float, float],
    title: str,
    ylim: tuple[int, int],
    cmlim: tuple[int, int],
    dpi: int,
    show: bool = False,
) -> None:
    """
    Generate a summary plot for the given date.
    Make sure the NetCDF file for the given date has been generated first.
    The output will be saved as a JPEG file with name derived from the input date
    resulting in a sibling file to the NetCDF file.

    Args:
        date (str): Date to plot in `YYYYMMDD` format.
        lat_lon_for_solpos (tuple[float, float]): Latitude and longitude for solar position calculation.
        title (str, optional): Title for the plot.
        ylim (tuple[float, float], optional): Limits for the y-axis.
        cmlim (tuple[float, float], optional): Limits passed to `pcolormesh`.
        dpi (int, optional): DPI to use for the plot.
        show (bool, optional): Whether to also show the plot. Defaults to `False`, meaning only the JPEG file is generated.
    """
    if not self._hmb_gen:
        raise ValueError(
            "Missing or invalid parameters. Call check_parameters() first."
        )

    return self._hmb_gen.plot_date(
        date,
        lat_lon_for_solpos,
        title,
        ylim,
        cmlim,
        dpi,
        show,
    )