afscgap

Library which allows for Pythonic access to the interacting with AFSC GAP.

This library supports Pythonic utilization of the Ground Fish Assessment Program (GAP) datasets produced by the Resource Assessment and Conservation Engineering (RACE) Division of the Alaska Fisheries Science Center (AFSC) as part of the National Oceanic and Atmospheric Administration (NOAA Fisheries). Note that this is a community-provided library and is not officially endorsed by NOAA.

(c) 2024 Regents of University of California / The Eric and Wendy Schmidt Center for Data Science and the Environment at UC Berkeley.

This file is part of afscgap released under the BSD 3-Clause License. See LICENSE.md.

   1"""Library which allows for Pythonic access to the interacting with AFSC GAP.
   2
   3This library supports Pythonic utilization of the Ground Fish Assessment Program (GAP) datasets
   4produced by the Resource Assessment and Conservation Engineering (RACE) Division of the Alaska
   5Fisheries Science Center (AFSC) as part of the National Oceanic and Atmospheric Administration
   6(NOAA Fisheries). Note that this is a community-provided library and is not officially endorsed by
   7NOAA.
   8
   9(c) 2024 Regents of University of California / The Eric and Wendy Schmidt Center
  10for Data Science and the Environment at UC Berkeley.
  11
  12This file is part of afscgap released under the BSD 3-Clause License. See
  13LICENSE.md.
  14"""
  15import typing
  16
  17import afscgap.cursor
  18import afscgap.flat
  19import afscgap.param
  20
  21from afscgap.typesdef import OPT_FLOAT
  22from afscgap.typesdef import INT_PARAM
  23from afscgap.typesdef import STR_PARAM
  24from afscgap.typesdef import OPT_INT
  25from afscgap.typesdef import OPT_STR
  26from afscgap.typesdef import OPT_REQUESTOR
  27
  28WARN_FUNCTION = typing.Optional[typing.Callable[[str], None]]
  29
  30DEFAULT_URL = 'https://data.pyafscgap.org'
  31
  32
  33class Query:
  34    """Entrypoint for the AFSC GAP Python library.
  35
  36    Facade for executing queries against AFSC GAP and builder to create those
  37    queries.
  38    """
  39
  40    def __init__(self, base_url: OPT_STR = None, requestor: OPT_REQUESTOR = None):
  41        """Create a new Query.
  42
  43        Args:
  44            base_url: The URL at which the flat files can be found. If None, will use
  45                default. See afscgap.DEFAULT_URL.
  46            requestor: Strategy to use for making HTTP requests. If None, will
  47                use a default as defined by afscgap.client.Cursor.
  48        """
  49        # URLs for data
  50        self._base_url = base_url
  51        self._requestor = requestor
  52
  53        # Filter parameters
  54        self._year: afscgap.param.Param = afscgap.param.EmptyParam()
  55        self._srvy: afscgap.param.Param = afscgap.param.EmptyParam()
  56        self._survey: afscgap.param.Param = afscgap.param.EmptyParam()
  57        self._survey_id: afscgap.param.Param = afscgap.param.EmptyParam()
  58        self._cruise: afscgap.param.Param = afscgap.param.EmptyParam()
  59        self._haul: afscgap.param.Param = afscgap.param.EmptyParam()
  60        self._stratum: afscgap.param.Param = afscgap.param.EmptyParam()
  61        self._station: afscgap.param.Param = afscgap.param.EmptyParam()
  62        self._vessel_name: afscgap.param.Param = afscgap.param.EmptyParam()
  63        self._vessel_id: afscgap.param.Param = afscgap.param.EmptyParam()
  64        self._date_time: afscgap.param.Param = afscgap.param.EmptyParam()
  65        self._latitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
  66        self._longitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
  67        self._species_code: afscgap.param.Param = afscgap.param.EmptyParam()
  68        self._common_name: afscgap.param.Param = afscgap.param.EmptyParam()
  69        self._scientific_name: afscgap.param.Param = afscgap.param.EmptyParam()
  70        self._taxon_confidence: afscgap.param.Param = afscgap.param.EmptyParam()
  71        self._cpue_kgha: afscgap.param.Param = afscgap.param.EmptyParam()
  72        self._cpue_kgkm2: afscgap.param.Param = afscgap.param.EmptyParam()
  73        self._cpue_kg1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
  74        self._cpue_noha: afscgap.param.Param = afscgap.param.EmptyParam()
  75        self._cpue_nokm2: afscgap.param.Param = afscgap.param.EmptyParam()
  76        self._cpue_no1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
  77        self._weight_kg: afscgap.param.Param = afscgap.param.EmptyParam()
  78        self._count: afscgap.param.Param = afscgap.param.EmptyParam()
  79        self._bottom_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
  80        self._surface_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
  81        self._depth_m: afscgap.param.Param = afscgap.param.EmptyParam()
  82        self._distance_fished_km: afscgap.param.Param = afscgap.param.EmptyParam()
  83        self._net_width_m: afscgap.param.Param = afscgap.param.EmptyParam()
  84        self._net_height_m: afscgap.param.Param = afscgap.param.EmptyParam()
  85        self._area_swept_ha: afscgap.param.Param = afscgap.param.EmptyParam()
  86        self._duration_hr: afscgap.param.Param = afscgap.param.EmptyParam()
  87
  88        # Query pararmeters
  89        self._limit: OPT_INT = None
  90        self._filter_incomplete: bool = False
  91        self._presence_only: bool = False
  92        self._suppress_large_warning: bool = False
  93        self._warn_function: WARN_FUNCTION = None
  94
  95    def filter_year(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
  96        max_val: OPT_FLOAT = None) -> 'Query':
  97        """Filter on year for the survey in which this observation was made.
  98
  99        Filter on year for the survey in which this observation was made,
 100        ovewritting all prior year filters on this Query if one was previously
 101        set.
 102
 103        Args:
 104            eq: The exact value that must be matched for a record to be
 105                returned. Pass None if no equality filter should be applied.
 106                Error thrown if min_val or max_val also provided.
 107            min_val: The minimum allowed value, inclusive. Pass None if no
 108                minimum value filter should be applied. Defaults to None. Error
 109                thrown if eq also proivded.
 110            max_val: The maximum allowed value, inclusive. Pass None if no
 111                maximum value filter should be applied. Defaults to None. Error
 112                thrown if eq also proivded.
 113
 114        Returns:
 115            This object for chaining if desired.
 116        """
 117        self._year = self._create_float_param(eq, min_val, max_val)
 118        return self
 119
 120    def filter_srvy(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 121        max_val: OPT_STR = None) -> 'Query':
 122        """Filter on haul survey short name.
 123
 124        Filter on the short name of the survey in which this observation was
 125        made. Pass None if no filter should be applied. Defaults to None. Note
 126        that common values include: NBS (N Bearing Sea), EBS (SE Bearing Sea),
 127        BSS (Bearing Sea Slope), GOA (Gulf of Alaska), and AI (Aleutian
 128        Islands). Overwrites all prior srvy filters if set on this Query.
 129
 130        Args:
 131            eq: The exact value that must be matched for a record to be
 132                returned. Pass None if no equality filter should be applied.
 133                Error thrown if min_val or max_val also provided.
 134            min_val: The minimum allowed value, inclusive. Pass None if no
 135                minimum value filter should be applied. Defaults to None. Error
 136                thrown if eq also proivded.
 137            max_val: The maximum allowed value, inclusive. Pass None if no
 138                maximum value filter should be applied. Defaults to None. Error
 139                thrown if eq also proivded.
 140
 141        Returns:
 142            This object for chaining if desired.
 143        """
 144        self._srvy = self._create_str_param(eq, min_val, max_val)
 145        return self
 146
 147    def filter_survey(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 148        max_val: OPT_STR = None) -> 'Query':
 149        """Filter on survey long name.
 150
 151        Filter on long form description of the survey in which the observation
 152        was made. Overwrites all prior survey filters if set on this Query.
 153
 154        Args:
 155            eq: The exact value that must be matched for a record to be
 156                returned. Pass None if no equality filter should be applied.
 157                Error thrown if min_val or max_val also provided.
 158            min_val: The minimum allowed value, inclusive. Pass None if no
 159                minimum value filter should be applied. Defaults to None. Error
 160                thrown if eq also proivded.
 161            max_val: The maximum allowed value, inclusive. Pass None if no
 162                maximum value filter should be applied. Defaults to None. Error
 163                thrown if eq also proivded.
 164
 165        Returns:
 166            This object for chaining if desired.
 167        """
 168        self._survey = self._create_str_param(eq, min_val, max_val)
 169        return self
 170
 171    def filter_survey_id(self, eq: OPT_FLOAT = None,
 172        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 173        """Filter on unique numeric ID for the survey.
 174
 175        Filter on unique numeric ID for the survey, overwritting prior survey ID
 176        filters if set on this Query.
 177
 178        Args:
 179            eq: The exact value that must be matched for a record to be
 180                returned. Pass None if no equality filter should be applied.
 181                Error thrown if min_val or max_val also provided.
 182            min_val: The minimum allowed value, inclusive. Pass None if no
 183                minimum value filter should be applied. Defaults to None. Error
 184                thrown if eq also proivded.
 185            max_val: The maximum allowed value, inclusive. Pass None if no
 186                maximum value filter should be applied. Defaults to None. Error
 187                thrown if eq also proivded.
 188
 189        Returns:
 190            This object for chaining if desired.
 191        """
 192        self._survey_id = self._create_float_param(eq, min_val, max_val)
 193        return self
 194
 195    def filter_cruise(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 196        max_val: OPT_FLOAT = None) -> 'Query':
 197        """Filter on cruise ID.
 198
 199        Filter on an ID uniquely identifying the cruise in which the observation
 200        was made. Overwrites all prior cruise filters on this Query.
 201
 202        Args:
 203            eq: The exact value that must be matched for a record to be
 204                returned. Pass None if no equality filter should be applied.
 205                Error thrown if min_val or max_val also provided.
 206            min_val: The minimum allowed value, inclusive. Pass None if no
 207                minimum value filter should be applied. Defaults to None. Error
 208                thrown if eq also proivded.
 209            max_val: The maximum allowed value, inclusive. Pass None if no
 210                maximum value filter should be applied. Defaults to None. Error
 211                thrown if eq also proivded.
 212
 213        Returns:
 214            This object for chaining if desired.
 215        """
 216        self._cruise = self._create_float_param(eq, min_val, max_val)
 217        return self
 218
 219    def filter_haul(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 220        max_val: OPT_FLOAT = None) -> 'Query':
 221        """Filter on haul identifier.
 222
 223        Filter on an ID uniquely identifying the haul in which this observation
 224        was made. Overwrites all prior haul filters on this Query.
 225
 226        Args:
 227            eq: The exact value that must be matched for a record to be
 228                returned. Pass None if no equality filter should be applied.
 229                Error thrown if min_val or max_val also provided.
 230            min_val: The minimum allowed value, inclusive. Pass None if no
 231                minimum value filter should be applied. Defaults to None. Error
 232                thrown if eq also proivded.
 233            max_val: The maximum allowed value, inclusive. Pass None if no
 234                maximum value filter should be applied. Defaults to None. Error
 235                thrown if eq also proivded.
 236
 237        Returns:
 238            This object for chaining if desired.
 239        """
 240        self._haul = self._create_float_param(eq, min_val, max_val)
 241        return self
 242
 243    def filter_stratum(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 244        max_val: OPT_FLOAT = None) -> 'Query':
 245        """Filter on unique ID for statistical area / survey combination.
 246
 247        Filter on unique ID for statistical area / survey combination,
 248        overwritting all prior stratum filters on Query.
 249
 250        Args:
 251            eq: The exact value that must be matched for a record to be
 252                returned. Pass None if no equality filter should be applied.
 253                Error thrown if min_val or max_val also provided.
 254            min_val: The minimum allowed value, inclusive. Pass None if no
 255                minimum value filter should be applied. Defaults to None. Error
 256                thrown if eq also proivded.
 257            max_val: The maximum allowed value, inclusive. Pass None if no
 258                maximum value filter should be applied. Defaults to None. Error
 259                thrown if eq also proivded.
 260
 261        Returns:
 262            This object for chaining if desired.
 263        """
 264        self._stratum = self._create_float_param(eq, min_val, max_val)
 265        return self
 266
 267    def filter_station(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 268        max_val: OPT_STR = None) -> 'Query':
 269        """Filter on station associated with the survey.
 270
 271        Filter on station associated with the survey, overwritting all prior
 272        station filters on this Query.
 273
 274        Args:
 275            eq: The exact value that must be matched for a record to be
 276                returned. Pass None if no equality filter should be applied.
 277                Error thrown if min_val or max_val also provided.
 278            min_val: The minimum allowed value, inclusive. Pass None if no
 279                minimum value filter should be applied. Defaults to None. Error
 280                thrown if eq also proivded.
 281            max_val: The maximum allowed value, inclusive. Pass None if no
 282                maximum value filter should be applied. Defaults to None. Error
 283                thrown if eq also proivded.
 284
 285        Returns:
 286            This object for chaining if desired.
 287        """
 288        self._station = self._create_str_param(eq, min_val, max_val)
 289        return self
 290
 291    def filter_vessel_name(self, eq: STR_PARAM = None,
 292        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 293        """Filter on unique ID describing the vessel that made this observation.
 294
 295        Filter on unique ID describing the vessel that made this observation,
 296        overwritting all prior vessel name filters on this Query.
 297
 298        Args:
 299            eq: The exact value that must be matched for a record to be
 300                returned. Pass None if no equality filter should be applied.
 301                Error thrown if min_val or max_val also provided.
 302            min_val: The minimum allowed value, inclusive. Pass None if no
 303                minimum value filter should be applied. Defaults to None. Error
 304                thrown if eq also proivded.
 305            max_val: The maximum allowed value, inclusive. Pass None if no
 306                maximum value filter should be applied. Defaults to None. Error
 307                thrown if eq also proivded.
 308
 309        Returns:
 310            This object for chaining if desired.
 311        """
 312        self._vessel_name = self._create_str_param(eq, min_val, max_val)
 313        return self
 314
 315    def filter_vessel_id(self, eq: OPT_FLOAT = None,
 316        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 317        """Filter on name of the vessel at the time the observation was made.
 318
 319        Filter on name of the vessel at the time the observation was made,
 320        overwritting all prior vessel ID filters on this Query.
 321
 322        Args:
 323            eq: The exact value that must be matched for a record to be
 324                returned. Pass None if no equality filter should be applied.
 325                Error thrown if min_val or max_val also provided.
 326            min_val: The minimum allowed value, inclusive. Pass None if no
 327                minimum value filter should be applied. Defaults to None. Error
 328                thrown if eq also proivded.
 329            max_val: The maximum allowed value, inclusive. Pass None if no
 330                maximum value filter should be applied. Defaults to None. Error
 331                thrown if eq also proivded.
 332
 333        Returns:
 334            This object for chaining if desired.
 335        """
 336        self._vessel_id = self._create_float_param(eq, min_val, max_val)
 337        return self
 338
 339    def filter_date_time(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 340        max_val: OPT_STR = None) -> 'Query':
 341        """Filter on the date and time of the haul.
 342
 343        Filter on the date and time of the haul as an ISO 8601 string. If given
 344        an ISO 8601 string, will afscgap.convert from ISO 8601 to the API
 345        datetime string format. Similarly, if given a dictionary, all values
 346        matching an ISO 8601 string will be afscgap.converted to the API
 347        datetime string format. Overwrites all prior date time filters on
 348        this Query.
 349
 350        Args:
 351            eq: The exact value that must be matched for a record to be
 352                returned. Pass None if no equality filter should be applied.
 353                Error thrown if min_val or max_val also provided.
 354            min_val: The minimum allowed value, inclusive. Pass None if no
 355                minimum value filter should be applied. Defaults to None. Error
 356                thrown if eq also proivded.
 357            max_val: The maximum allowed value, inclusive. Pass None if no
 358                maximum value filter should be applied. Defaults to None. Error
 359                thrown if eq also proivded.
 360
 361        Returns:
 362            This object for chaining if desired.
 363        """
 364        self._date_time = self._create_str_param(eq, min_val, max_val)
 365        return self
 366
 367    def filter_latitude(self, eq: OPT_FLOAT = None,
 368        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 369        units: str = 'dd') -> 'Query':
 370        """Filter on latitude in decimal degrees associated with the haul.
 371
 372        Filter on latitude in decimal degrees associated with the haul,
 373        overwritting all prior latitude filters on this Query.
 374
 375        Args:
 376            eq: The exact value that must be matched for a record to be
 377                returned. Pass None if no equality filter should be applied.
 378                Error thrown if min_val or max_val also provided.
 379            min_val: The minimum allowed value, inclusive. Pass None if no
 380                minimum value filter should be applied. Defaults to None. Error
 381                thrown if eq also proivded.
 382            max_val: The maximum allowed value, inclusive. Pass None if no
 383                maximum value filter should be applied. Defaults to None. Error
 384                thrown if eq also proivded.
 385            units: The units in which the filter values are provided. Currently
 386                only dd supported.
 387
 388        Returns:
 389            This object for chaining if desired.
 390        """
 391        self._latitude_dd = self._create_float_param(
 392            afscgap.convert.convert(eq, units, 'dd'),
 393            afscgap.convert.convert(min_val, units, 'dd'),
 394            afscgap.convert.convert(max_val, units, 'dd')
 395        )
 396        return self
 397
 398    def filter_longitude(self, eq: OPT_FLOAT = None,
 399        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 400        units: str = 'dd') -> 'Query':
 401        """Filter on longitude in decimal degrees associated with the haul.
 402
 403        Filter on longitude in decimal degrees associated with the haul,
 404        overwritting all prior longitude filters on this Query.
 405
 406        Args:
 407            eq: The exact value that must be matched for a record to be
 408                returned. Pass None if no equality filter should be applied.
 409                Error thrown if min_val or max_val also provided.
 410            min_val: The minimum allowed value, inclusive. Pass None if no
 411                minimum value filter should be applied. Defaults to None. Error
 412                thrown if eq also proivded.
 413            max_val: The maximum allowed value, inclusive. Pass None if no
 414                maximum value filter should be applied. Defaults to None. Error
 415                thrown if eq also proivded.
 416            units: The units in which the filter values are provided. Currently
 417                only dd supported.
 418
 419        Returns:
 420            This object for chaining if desired.
 421        """
 422        self._longitude_dd = self._create_float_param(
 423            afscgap.convert.convert(eq, units, 'dd'),
 424            afscgap.convert.convert(min_val, units, 'dd'),
 425            afscgap.convert.convert(max_val, units, 'dd')
 426        )
 427        return self
 428
 429    def filter_species_code(self, eq: OPT_FLOAT = None,
 430        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 431        """Filter on unique ID associated with the species observed.
 432
 433        Filter on unique ID associated with the species observed, overwritting
 434        all prior species code filters on this Query.
 435
 436        Args:
 437            eq: The exact value that must be matched for a record to be
 438                returned. Pass None if no equality filter should be applied.
 439                Error thrown if min_val or max_val also provided.
 440            min_val: The minimum allowed value, inclusive. Pass None if no
 441                minimum value filter should be applied. Defaults to None. Error
 442                thrown if eq also proivded.
 443            max_val: The maximum allowed value, inclusive. Pass None if no
 444                maximum value filter should be applied. Defaults to None. Error
 445                thrown if eq also proivded.
 446
 447        Returns:
 448            This object for chaining if desired.
 449        """
 450        self._species_code = self._create_float_param(eq, min_val, max_val)
 451        return self
 452
 453    def filter_common_name(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 454        max_val: OPT_STR = None) -> 'Query':
 455        """Filter on the "common name" associated with the species observed.
 456
 457        Filter on the "common name" associated with the species observed,
 458        overwritting all prior common name filters on this Query.
 459
 460        Args:
 461            eq: The exact value that must be matched for a record to be
 462                returned. Pass None if no equality filter should be applied.
 463                Error thrown if min_val or max_val also provided.
 464            min_val: The minimum allowed value, inclusive. Pass None if no
 465                minimum value filter should be applied. Defaults to None. Error
 466                thrown if eq also proivded.
 467            max_val: The maximum allowed value, inclusive. Pass None if no
 468                maximum value filter should be applied. Defaults to None. Error
 469                thrown if eq also proivded.
 470
 471        Returns:
 472            This object for chaining if desired.
 473        """
 474        self._common_name = self._create_str_param(eq, min_val, max_val)
 475        return self
 476
 477    def filter_scientific_name(self, eq: STR_PARAM = None,
 478        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 479        """Filter on the "scientific name" associated with the species observed.
 480
 481        Filter on the "scientific name" associated with the species observed,
 482        overwritting all prior scientific name filters on this Query.
 483
 484        Args:
 485            eq: The exact value that must be matched for a record to be
 486                returned. Pass None if no equality filter should be applied.
 487                Error thrown if min_val or max_val also provided.
 488            min_val: The minimum allowed value, inclusive. Pass None if no
 489                minimum value filter should be applied. Defaults to None. Error
 490                thrown if eq also proivded.
 491            max_val: The maximum allowed value, inclusive. Pass None if no
 492                maximum value filter should be applied. Defaults to None. Error
 493                thrown if eq also proivded.
 494
 495        Returns:
 496            This object for chaining if desired.
 497        """
 498        self._scientific_name = self._create_str_param(eq, min_val, max_val)
 499        return self
 500
 501    def filter_taxon_confidence(self, eq: STR_PARAM = None,
 502        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 503        """Filter on confidence flag regarding ability to identify species.
 504
 505        Filter on confidence flag regarding ability to identify species,
 506        overwritting all taxon confidence filters on this Query.
 507
 508        Args:
 509            eq: The exact value that must be matched for a record to be
 510                returned. Pass None if no equality filter should be applied.
 511                Error thrown if min_val or max_val also provided.
 512            min_val: The minimum allowed value, inclusive. Pass None if no
 513                minimum value filter should be applied. Defaults to None. Error
 514                thrown if eq also proivded.
 515            max_val: The maximum allowed value, inclusive. Pass None if no
 516                maximum value filter should be applied. Defaults to None. Error
 517                thrown if eq also proivded.
 518
 519        Returns:
 520            This object for chaining if desired.
 521        """
 522        self._taxon_confidence = self._create_str_param(eq, min_val, max_val)
 523        return self
 524
 525    def filter_cpue_weight(self, eq: OPT_FLOAT = None,
 526        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 527        units: str = 'kg/ha') -> 'Query':
 528        """Filter on catch per unit effort.
 529
 530        Filter on catch per unit effort as weight divided by net area if
 531        available. Overwrites all prior CPUE weight filters applied to this
 532        Query.
 533
 534        Args:
 535            eq: The exact value that must be matched for a record to be
 536                returned. Pass None if no equality filter should be applied.
 537                Error thrown if min_val or max_val also provided.
 538            min_val: The minimum allowed value, inclusive. Pass None if no
 539                minimum value filter should be applied. Defaults to None. Error
 540                thrown if eq also proivded.
 541            max_val: The maximum allowed value, inclusive. Pass None if no
 542                maximum value filter should be applied. Defaults to None. Error
 543                thrown if eq also proivded.
 544            units: The units for the catch per unit effort provided. Options:
 545                kg/ha, kg/km2, kg1000/km2. Defaults to kg/ha.
 546
 547        Returns:
 548            This object for chaining if desired.
 549        """
 550        param = self._create_float_param(eq, min_val, max_val)
 551
 552        self._cpue_kgha = afscgap.param.EmptyParam()
 553        self._cpue_kgkm2 = afscgap.param.EmptyParam()
 554        self._cpue_kg1000km2 = afscgap.param.EmptyParam()
 555
 556        if units == 'kg/ha':
 557            self._cpue_kgha = param
 558        elif units == 'kg/km2':
 559            self._cpue_kgkm2 = param
 560        elif units == 'kg1000/km2':
 561            self._cpue_kg1000km2 = param
 562        else:
 563            raise RuntimeError('Unrecognized units ' + units)
 564
 565        return self
 566
 567    def filter_cpue_count(self, eq: OPT_FLOAT = None,
 568        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 569        units: str = 'count/ha') -> 'Query':
 570        """Filter catch per unit effort as count over area in hectares.
 571
 572        Filter on catch number divided by net sweep area if available (count /
 573        hectares). Overwrites all prior CPUE count filters applied to this
 574        Query.
 575
 576        Args:
 577            eq: The exact value that must be matched for a record to be
 578                returned. Pass None if no equality filter should be applied.
 579                Error thrown if min_val or max_val also provided.
 580            min_val: The minimum allowed value, inclusive. Pass None if no
 581                minimum value filter should be applied. Defaults to None. Error
 582                thrown if eq also proivded.
 583            max_val: The maximum allowed value, inclusive. Pass None if no
 584                maximum value filter should be applied. Defaults to None. Error
 585                thrown if eq also proivded.
 586            units: The units for the given catch per unit effort. Options:
 587                count/ha, count/km2, and count1000/km2. Defaults to count/ha.
 588
 589        Returns:
 590            This object for chaining if desired.
 591        """
 592        param = self._create_float_param(eq, min_val, max_val)
 593
 594        self._cpue_noha = afscgap.param.EmptyParam()
 595        self._cpue_nokm2 = afscgap.param.EmptyParam()
 596        self._cpue_no1000km2 = afscgap.param.EmptyParam()
 597
 598        if units == 'count/ha':
 599            self._cpue_noha = param
 600        elif units == 'count/km2':
 601            self._cpue_nokm2 = param
 602        elif units == 'count1000/km2':
 603            self._cpue_no1000km2 = param
 604        else:
 605            raise RuntimeError('Unrecognized units ' + units)
 606
 607        return self
 608
 609    def filter_weight(self, eq: OPT_FLOAT = None,
 610        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 611        units: str = 'kg') -> 'Query':
 612        """Filter on taxon weight (kg) if available.
 613
 614        Filter on taxon weight (kg) if available, overwrites all prior weight
 615        filters applied to this Query.
 616
 617        Args:
 618            eq: The exact value that must be matched for a record to be
 619                returned. Pass None if no equality filter should be applied.
 620                Error thrown if min_val or max_val also provided.
 621            min_val: The minimum allowed value, inclusive. Pass None if no
 622                minimum value filter should be applied. Defaults to None. Error
 623                thrown if eq also proivded.
 624            max_val: The maximum allowed value, inclusive. Pass None if no
 625                maximum value filter should be applied. Defaults to None. Error
 626                thrown if eq also proivded.
 627            units: The units in which the weight are given. Options are
 628                g, kg for grams and kilograms respectively. Deafults to kg.
 629
 630        Returns:
 631            This object for chaining if desired.
 632        """
 633        self._weight_kg = self._create_float_param(
 634            afscgap.convert.convert(eq, units, 'kg'),
 635            afscgap.convert.convert(min_val, units, 'kg'),
 636            afscgap.convert.convert(max_val, units, 'kg')
 637        )
 638        return self
 639
 640    def filter_count(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 641        max_val: OPT_FLOAT = None) -> 'Query':
 642        """Filter on total number of organism individuals in haul.
 643
 644        Filter on total number of organism individuals in haul, overwrites all
 645        prior count filters applied to this Query.
 646
 647        Args:
 648            eq: The exact value that must be matched for a record to be
 649                returned. Pass None if no equality filter should be applied.
 650                Error thrown if min_val or max_val also provided.
 651            min_val: The minimum allowed value, inclusive. Pass None if no
 652                minimum value filter should be applied. Defaults to None. Error
 653                thrown if eq also proivded.
 654            max_val: The maximum allowed value, inclusive. Pass None if no
 655                maximum value filter should be applied. Defaults to None. Error
 656                thrown if eq also proivded.
 657
 658        Returns:
 659            This object for chaining if desired.
 660        """
 661        self._count = self._create_float_param(eq, min_val, max_val)
 662        return self
 663
 664    def filter_bottom_temperature(self, eq: OPT_FLOAT = None,
 665        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 666        units: str = 'c') -> 'Query':
 667        """Filter on bottom temperature.
 668
 669        Filter on bottom temperature associated with observation if available in
 670        the units given. Overwrites all prior bottom temperature filters applied
 671        to this Query.
 672
 673        Args:
 674            eq: The exact value that must be matched for a record to be
 675                returned. Pass None if no equality filter should be applied.
 676                Error thrown if min_val or max_val also provided.
 677            min_val: The minimum allowed value, inclusive. Pass None if no
 678                minimum value filter should be applied. Defaults to None. Error
 679                thrown if eq also proivded.
 680            max_val: The maximum allowed value, inclusive. Pass None if no
 681                maximum value filter should be applied. Defaults to None. Error
 682                thrown if eq also proivded.
 683            units: The units in which the temperature filter values are given.
 684                Options: c or f for Celcius and Fahrenheit respectively.
 685                Defaults to c.
 686
 687        Returns:
 688            This object for chaining if desired.
 689        """
 690        self._bottom_temperature_c = self._create_float_param(
 691            afscgap.convert.convert(eq, units, 'c'),
 692            afscgap.convert.convert(min_val, units, 'c'),
 693            afscgap.convert.convert(max_val, units, 'c')
 694        )
 695        return self
 696
 697    def filter_surface_temperature(self, eq: OPT_FLOAT = None,
 698        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 699        units: str = 'c') -> 'Query':
 700        """Filter on surface temperature.
 701
 702        Filter on surface temperature associated with observation if available
 703        in the units given. Overwrites all prior bottom temperature filters
 704        applied to this Query.
 705
 706        Args:
 707            eq: The exact value that must be matched for a record to be
 708                returned. Pass None if no equality filter should be applied.
 709                Error thrown if min_val or max_val also provided.
 710            min_val: The minimum allowed value, inclusive. Pass None if no
 711                minimum value filter should be applied. Defaults to None. Error
 712                thrown if eq also proivded.
 713            max_val: The maximum allowed value, inclusive. Pass None if no
 714                maximum value filter should be applied. Defaults to None. Error
 715                thrown if eq also proivded.
 716            units: The units in which the temperature filter values are given.
 717                Options: c or f for Celcius and Fahrenheit respectively.
 718                Defaults to c.
 719
 720        Returns:
 721            This object for chaining if desired.
 722        """
 723        self._surface_temperature_c = self._create_float_param(
 724            afscgap.convert.convert(eq, units, 'c'),
 725            afscgap.convert.convert(min_val, units, 'c'),
 726            afscgap.convert.convert(max_val, units, 'c')
 727        )
 728        return self
 729
 730    def filter_depth(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 731        max_val: OPT_FLOAT = None, units: str = 'm') -> 'Query':
 732        """Filter on depth of the bottom in meters.
 733
 734        Filter on depth of the bottom in meters, overwrites all prior depth
 735        filters applied to this Query.
 736
 737        Args:
 738            eq: The exact value that must be matched for a record to be
 739                returned. Pass None if no equality filter should be applied.
 740                Error thrown if min_val or max_val also provided.
 741            min_val: The minimum allowed value, inclusive. Pass None if no
 742                minimum value filter should be applied. Defaults to None. Error
 743                thrown if eq also proivded.
 744            max_val: The maximum allowed value, inclusive. Pass None if no
 745                maximum value filter should be applied. Defaults to None. Error
 746                thrown if eq also proivded.
 747            units: The units in which the distance are given. Options:
 748                m or km for meters and kilometers respectively. Defaults to m.
 749
 750        Returns:
 751            This object for chaining if desired.
 752        """
 753        self._depth_m = self._create_float_param(
 754            afscgap.convert.convert(eq, units, 'm'),
 755            afscgap.convert.convert(min_val, units, 'm'),
 756            afscgap.convert.convert(max_val, units, 'm')
 757        )
 758        return self
 759
 760    def filter_distance_fished(self, eq: OPT_FLOAT = None,
 761        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 762        units: str = 'm') -> 'Query':
 763        """Filter on distance of the net fished.
 764
 765        Filter on distance of the net fished, overwritting prior distance fished
 766        filters applied to this Query.
 767
 768        Args:
 769            eq: The exact value that must be matched for a record to be
 770                returned. Pass None if no equality filter should be applied.
 771                Error thrown if min_val or max_val also provided.
 772            min_val: The minimum allowed value, inclusive. Pass None if no
 773                minimum value filter should be applied. Defaults to None. Error
 774                thrown if eq also proivded.
 775            max_val: The maximum allowed value, inclusive. Pass None if no
 776                maximum value filter should be applied. Defaults to None. Error
 777                thrown if eq also proivded.
 778            units: The units in which the distance values are given. Options:
 779                m or km for meters and kilometers respectively. Defaults to m.
 780
 781        Returns:
 782            This object for chaining if desired.
 783        """
 784        def convert_to_km(target, units):
 785            return afscgap.convert.convert(target, units, 'km')
 786
 787        self._distance_fished_km = self._create_float_param(
 788            convert_to_km(eq, units),
 789            convert_to_km(min_val, units),
 790            convert_to_km(max_val, units)
 791        )
 792        return self
 793
 794    def filter_net_width(self, eq: OPT_FLOAT = None,
 795        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 796        units: str = 'm') -> 'Query':
 797        """Filter on distance of the net fished.
 798
 799        Filter on distance of the net fished, overwritting prior net width
 800        filters applied to this Query.
 801
 802        Args:
 803            eq: The exact value that must be matched for a record to be
 804                returned. Pass None if no equality filter should be applied.
 805                Error thrown if min_val or max_val also provided.
 806            min_val: The minimum allowed value, inclusive. Pass None if no
 807                minimum value filter should be applied. Defaults to None. Error
 808                thrown if eq also proivded.
 809            max_val: The maximum allowed value, inclusive. Pass None if no
 810                maximum value filter should be applied. Defaults to None. Error
 811                thrown if eq also proivded.
 812            units: The units in which the distance should be returned. Options:
 813                m or km for meters and kilometers respectively. Defaults to m.
 814
 815        Returns:
 816            This object for chaining if desired.
 817        """
 818        self._net_width_m = self._create_float_param(
 819            afscgap.convert.convert(eq, units, 'm'),
 820            afscgap.convert.convert(min_val, units, 'm'),
 821            afscgap.convert.convert(max_val, units, 'm')
 822        )
 823        return self
 824
 825    def filter_net_height(self, eq: OPT_FLOAT = None,
 826        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 827        units: str = 'm') -> 'Query':
 828        """Filter on height of the net fished.
 829
 830        Filter on height of the net fished, overwritting prior net height
 831        filters applied to this Query.
 832
 833        Args:
 834            eq: The exact value that must be matched for a record to be
 835                returned. Pass None if no equality filter should be applied.
 836                Error thrown if min_val or max_val also provided.
 837            min_val: The minimum allowed value, inclusive. Pass None if no
 838                minimum value filter should be applied. Defaults to None. Error
 839                thrown if eq also proivded.
 840            max_val: The maximum allowed value, inclusive. Pass None if no
 841                maximum value filter should be applied. Defaults to None. Error
 842                thrown if eq also proivded.
 843            units: The units in which the distance should be returned. Options:
 844                m or km for meters and kilometers respectively. Defaults to m.
 845
 846        Returns:
 847            This object for chaining if desired.
 848        """
 849        self._net_height_m = self._create_float_param(
 850            afscgap.convert.convert(eq, units, 'm'),
 851            afscgap.convert.convert(min_val, units, 'm'),
 852            afscgap.convert.convert(max_val, units, 'm')
 853        )
 854        return self
 855
 856    def filter_area_swept(self, eq: OPT_FLOAT = None,
 857        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 858        units: str = 'm') -> 'Query':
 859        """Filter on area covered by the net while fishing.
 860
 861        Filter on area covered by the net while fishing, overwritting prior
 862        area swept filters applied to this Query.
 863
 864        Args:
 865            eq: The exact value that must be matched for a record to be
 866                returned. Pass None if no equality filter should be applied.
 867                Error thrown if min_val or max_val also provided.
 868            min_val: The minimum allowed value, inclusive. Pass None if no
 869                minimum value filter should be applied. Defaults to None. Error
 870                thrown if eq also proivded.
 871            max_val: The maximum allowed value, inclusive. Pass None if no
 872                maximum value filter should be applied. Defaults to None. Error
 873                thrown if eq also proivded.
 874            units: The units in which the area should be returned. Options:
 875                ha, m2, km2. Defaults to ha.
 876
 877        Returns:
 878            This object for chaining if desired.
 879        """
 880        self._area_swept_ha = self._create_float_param(
 881            afscgap.convert.convert(eq, units, 'ha'),
 882            afscgap.convert.convert(min_val, units, 'ha'),
 883            afscgap.convert.convert(max_val, units, 'ha')
 884        )
 885        return self
 886
 887    def filter_duration(self, eq: OPT_FLOAT = None,
 888        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 889        units: str = 'hr') -> 'Query':
 890        """Filter on duration of the haul.
 891
 892        Filter on duration of the haul, ovewritting all prior duration filters
 893        applied to this Query.
 894
 895        Args:
 896            eq: The exact value that must be matched for a record to be
 897                returned. Pass None if no equality filter should be applied.
 898                Error thrown if min_val or max_val also provided.
 899            min_val: The minimum allowed value, inclusive. Pass None if no
 900                minimum value filter should be applied. Defaults to None. Error
 901                thrown if eq also proivded.
 902            max_val: The maximum allowed value, inclusive. Pass None if no
 903                maximum value filter should be applied. Defaults to None. Error
 904                thrown if eq also proivded.
 905            units: The units in which the duration should be returned. Options:
 906                day, hr, min. Defaults to hr.
 907
 908        Returns:
 909            This object for chaining if desired.
 910        """
 911        self._duration_hr = self._create_float_param(
 912            afscgap.convert.convert(eq, units, 'hr'),
 913            afscgap.convert.convert(min_val, units, 'hr'),
 914            afscgap.convert.convert(max_val, units, 'hr')
 915        )
 916        return self
 917
 918    def set_limit(self, limit: OPT_INT) -> 'Query':
 919        """Set the max number of results.
 920
 921        Set the max number of results, overwritting prior limit settings on this
 922        Query.
 923
 924        Args:
 925            limit: The maximum number of results to retrieve per HTTP request.
 926                If None or not provided, will use API's default.
 927
 928        Returns:
 929            This object for chaining if desired.
 930        """
 931        self._limit = limit
 932        return self
 933
 934    def set_filter_incomplete(self, filter_incomplete: bool) -> 'Query':
 935        """Indicate if incomplete records should be filtered out.
 936
 937        Indicate if incomplete records should be filtered out, overwritting
 938        prior incomplete filter settings on this Query.
 939
 940        Args:
 941            filter_incomplete: Flag indicating if "incomplete" records should be
 942                filtered. If true, "incomplete" records are silently filtered
 943                from the results, putting them in the invalid records queue. If
 944                false, they are included and their is_complete() will return
 945                false. Defaults to false.
 946
 947        Returns:
 948            This object for chaining if desired.
 949        """
 950        self._filter_incomplete = filter_incomplete
 951        return self
 952
 953    def set_presence_only(self, presence_only: bool) -> 'Query':
 954        """Indicate if zero catch inference should be enabled.
 955
 956        Indicate if zero catch inference should be enabled, overwritting prior
 957        abscence / zero catch data settings on this Query.
 958
 959        Args:
 960            presence_only: Flag indicating if abscence / zero catch data should
 961                be inferred. If false, will run abscence data inference. If
 962                true, will return presence only data as returned by the NOAA API
 963                service. Defaults to true.
 964
 965        Returns:
 966            This object for chaining if desired.
 967        """
 968        self._presence_only = presence_only
 969        return self
 970
 971    def set_suppress_large_warning(self, supress: bool) -> 'Query':
 972        """Indicate if the large results warning should be supressed.
 973
 974        Indicate if the large results warning should be supressed, overwritting
 975        prior large results warning supressions settings on this Query.
 976
 977        Args:
 978            suppress_large_warning: Indicate if the library should warn when an
 979                operation may consume a large amount of memory. If true, the
 980                warning will not be emitted. Defaults to true.
 981
 982        Returns:
 983            This object for chaining if desired.
 984        """
 985        self._suppress_large_warning = supress
 986        return self
 987
 988    def set_warn_function(self, warn_function: WARN_FUNCTION) -> 'Query':
 989        """Indicate how warnings should be emitted.
 990
 991        Indicate how warnings should be emitted, overwritting the prior warning
 992        function settings on this Query.
 993
 994        Args:
 995            warn_function: Function to call with a message describing warnings
 996                encountered. If None, will use warnings.warn. Defaults to None.
 997
 998        Returns:
 999            This object for chaining if desired.
1000        """
1001        self._warn_function = warn_function
1002        return self
1003
1004    def execute(self) -> afscgap.cursor.Cursor:
1005        """Execute the query built up in this object.
1006
1007        Execute the query built up in this object using its current state. Note
1008        that later changes to this builder will not impact prior returned
1009        Cursors from execute.
1010
1011        Returns:
1012            Cursor to manage HTTP requests and query results.
1013        """
1014        params_dict = {
1015            'year': self._year,
1016            'srvy': self._srvy,
1017            'survey': self._survey,
1018            'survey_id': self._survey_id,
1019            'cruise': self._cruise,
1020            'haul': self._haul,
1021            'stratum': self._stratum,
1022            'station': self._station,
1023            'vessel_name': self._vessel_name,
1024            'vessel_id': self._vessel_id,
1025            'date_time': self._date_time,
1026            'latitude_dd': self._latitude_dd,
1027            'longitude_dd': self._longitude_dd,
1028            'species_code': self._species_code,
1029            'common_name': self._common_name,
1030            'scientific_name': self._scientific_name,
1031            'taxon_confidence': self._taxon_confidence,
1032            'cpue_kgha': self._cpue_kgha,
1033            'cpue_kgkm2': self._cpue_kgkm2,
1034            'cpue_kg1000km2': self._cpue_kg1000km2,
1035            'cpue_noha': self._cpue_noha,
1036            'cpue_nokm2': self._cpue_nokm2,
1037            'cpue_no1000km2': self._cpue_no1000km2,
1038            'weight_kg': self._weight_kg,
1039            'count': self._count,
1040            'bottom_temperature_c': self._bottom_temperature_c,
1041            'surface_temperature_c': self._surface_temperature_c,
1042            'depth_m': self._depth_m,
1043            'distance_fished_km': self._distance_fished_km,
1044            'net_width_m': self._net_width_m,
1045            'net_height_m': self._net_height_m,
1046            'area_swept_ha': self._area_swept_ha,
1047            'duration_hr': self._duration_hr
1048        }
1049
1050        meta_params = afscgap.flat_model.ExecuteMetaParams(
1051            self._base_url if self._base_url else DEFAULT_URL,
1052            self._requestor,
1053            self._limit,
1054            self._filter_incomplete,
1055            self._presence_only,
1056            self._suppress_large_warning,
1057            self._warn_function
1058        )
1059
1060        return afscgap.flat.execute(params_dict, meta_params)
1061
1062    def _create_str_param(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
1063        max_val: OPT_STR = None) -> afscgap.param.Param:
1064        """Create a new string parameter.
1065
1066        Args:
1067            eq: The exact value that must be matched for a record to be
1068                returned. Pass None if no equality filter should be applied.
1069                Error thrown if min_val or max_val also provided.
1070            min_val: The minimum allowed value, inclusive. Pass None if no
1071                minimum value filter should be applied. Defaults to None. Error
1072                thrown if eq also proivded.
1073            max_val: The maximum allowed value, inclusive. Pass None if no
1074                maximum value filter should be applied. Defaults to None. Error
1075                thrown if eq also proivded.
1076
1077        Returns:
1078            Newly initalized parameter.
1079        """
1080        param_type = self._get_param_type(eq, min_val, max_val)
1081        strategy = {
1082            'empty': lambda: afscgap.param.EmptyParam(),
1083            'equals': lambda: afscgap.param.StrEqualsParam(eq),  # type: ignore
1084            'range': lambda: afscgap.param.StrRangeParam(min_val, max_val)  # type: ignore
1085        }[param_type]
1086        return strategy()  # type: ignore
1087
1088    def _create_float_param(self, eq: OPT_FLOAT = None,
1089        min_val: OPT_FLOAT = None,
1090        max_val: OPT_FLOAT = None) -> afscgap.param.Param:
1091        """Create a new float parameter.
1092
1093        Args:
1094            eq: The exact value that must be matched for a record to be
1095                returned. Pass None if no equality filter should be applied.
1096                Error thrown if min_val or max_val also provided.
1097            min_val: The minimum allowed value, inclusive. Pass None if no
1098                minimum value filter should be applied. Defaults to None. Error
1099                thrown if eq also proivded.
1100            max_val: The maximum allowed value, inclusive. Pass None if no
1101                maximum value filter should be applied. Defaults to None. Error
1102                thrown if eq also proivded.
1103
1104        Returns:
1105            Newly initalized parameter.
1106        """
1107        param_type = self._get_param_type(eq, min_val, max_val)
1108        strategy = {
1109            'empty': lambda: afscgap.param.EmptyParam(),
1110            'equals': lambda: afscgap.param.FloatEqualsParam(eq),    # type: ignore
1111            'range': lambda: afscgap.param.FloatRangeParam(min_val, max_val)   # type: ignore
1112        }[param_type]
1113        return strategy()  # type: ignore
1114
1115    def _create_int_param(self, eq: INT_PARAM = None, min_val: OPT_INT = None,
1116        max_val: OPT_INT = None) -> afscgap.param.Param:
1117        """Create a new int parameter.
1118
1119        Args:
1120            eq: The exact value that must be matched for a record to be
1121                returned. Pass None if no equality filter should be applied.
1122                Error thrown if min_val or max_val also provided.
1123            min_val: The minimum allowed value, inclusive. Pass None if no
1124                minimum value filter should be applied. Defaults to None. Error
1125                thrown if eq also proivded.
1126            max_val: The maximum allowed value, inclusive. Pass None if no
1127                maximum value filter should be applied. Defaults to None. Error
1128                thrown if eq also proivded.
1129
1130        Returns:
1131            Newly initalized parameter.
1132        """
1133        param_type = self._get_param_type(eq, min_val, max_val)
1134        strategy = {
1135            'empty': lambda: afscgap.param.EmptyParam(),
1136            'equals': lambda: afscgap.param.IntEqualsParam(eq),  # type: ignore
1137            'range': lambda: afscgap.param.IntRangeParam(min_val, max_val)  # type: ignore
1138        }[param_type]
1139        return strategy()  # type: ignore
1140
1141    def _get_param_type(self, eq, min_val, max_val) -> str:
1142        """Determine how the parameter should be interpreted.
1143
1144        Args:
1145            eq: The value for equality or None if no equals filter.
1146            min_val: The minimum value or None if no minimum filter.
1147            max_val: The maximum value or None if no maximum filter.
1148
1149        Returns:
1150            One of the following as a string: empty, equals, range.
1151        """
1152        if eq is None:
1153            if min_val is None and max_val is None:
1154                return 'empty'
1155            else:
1156                return 'range'
1157        else:
1158            if min_val is not None or max_val is not None:
1159                raise RuntimeError('Both range and equality filters provided.')
1160            else:
1161                return 'equals'
WARN_FUNCTION = typing.Optional[typing.Callable[[str], NoneType]]
DEFAULT_URL = 'https://data.pyafscgap.org'
class Query:
  34class Query:
  35    """Entrypoint for the AFSC GAP Python library.
  36
  37    Facade for executing queries against AFSC GAP and builder to create those
  38    queries.
  39    """
  40
  41    def __init__(self, base_url: OPT_STR = None, requestor: OPT_REQUESTOR = None):
  42        """Create a new Query.
  43
  44        Args:
  45            base_url: The URL at which the flat files can be found. If None, will use
  46                default. See afscgap.DEFAULT_URL.
  47            requestor: Strategy to use for making HTTP requests. If None, will
  48                use a default as defined by afscgap.client.Cursor.
  49        """
  50        # URLs for data
  51        self._base_url = base_url
  52        self._requestor = requestor
  53
  54        # Filter parameters
  55        self._year: afscgap.param.Param = afscgap.param.EmptyParam()
  56        self._srvy: afscgap.param.Param = afscgap.param.EmptyParam()
  57        self._survey: afscgap.param.Param = afscgap.param.EmptyParam()
  58        self._survey_id: afscgap.param.Param = afscgap.param.EmptyParam()
  59        self._cruise: afscgap.param.Param = afscgap.param.EmptyParam()
  60        self._haul: afscgap.param.Param = afscgap.param.EmptyParam()
  61        self._stratum: afscgap.param.Param = afscgap.param.EmptyParam()
  62        self._station: afscgap.param.Param = afscgap.param.EmptyParam()
  63        self._vessel_name: afscgap.param.Param = afscgap.param.EmptyParam()
  64        self._vessel_id: afscgap.param.Param = afscgap.param.EmptyParam()
  65        self._date_time: afscgap.param.Param = afscgap.param.EmptyParam()
  66        self._latitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
  67        self._longitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
  68        self._species_code: afscgap.param.Param = afscgap.param.EmptyParam()
  69        self._common_name: afscgap.param.Param = afscgap.param.EmptyParam()
  70        self._scientific_name: afscgap.param.Param = afscgap.param.EmptyParam()
  71        self._taxon_confidence: afscgap.param.Param = afscgap.param.EmptyParam()
  72        self._cpue_kgha: afscgap.param.Param = afscgap.param.EmptyParam()
  73        self._cpue_kgkm2: afscgap.param.Param = afscgap.param.EmptyParam()
  74        self._cpue_kg1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
  75        self._cpue_noha: afscgap.param.Param = afscgap.param.EmptyParam()
  76        self._cpue_nokm2: afscgap.param.Param = afscgap.param.EmptyParam()
  77        self._cpue_no1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
  78        self._weight_kg: afscgap.param.Param = afscgap.param.EmptyParam()
  79        self._count: afscgap.param.Param = afscgap.param.EmptyParam()
  80        self._bottom_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
  81        self._surface_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
  82        self._depth_m: afscgap.param.Param = afscgap.param.EmptyParam()
  83        self._distance_fished_km: afscgap.param.Param = afscgap.param.EmptyParam()
  84        self._net_width_m: afscgap.param.Param = afscgap.param.EmptyParam()
  85        self._net_height_m: afscgap.param.Param = afscgap.param.EmptyParam()
  86        self._area_swept_ha: afscgap.param.Param = afscgap.param.EmptyParam()
  87        self._duration_hr: afscgap.param.Param = afscgap.param.EmptyParam()
  88
  89        # Query pararmeters
  90        self._limit: OPT_INT = None
  91        self._filter_incomplete: bool = False
  92        self._presence_only: bool = False
  93        self._suppress_large_warning: bool = False
  94        self._warn_function: WARN_FUNCTION = None
  95
  96    def filter_year(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
  97        max_val: OPT_FLOAT = None) -> 'Query':
  98        """Filter on year for the survey in which this observation was made.
  99
 100        Filter on year for the survey in which this observation was made,
 101        ovewritting all prior year filters on this Query if one was previously
 102        set.
 103
 104        Args:
 105            eq: The exact value that must be matched for a record to be
 106                returned. Pass None if no equality filter should be applied.
 107                Error thrown if min_val or max_val also provided.
 108            min_val: The minimum allowed value, inclusive. Pass None if no
 109                minimum value filter should be applied. Defaults to None. Error
 110                thrown if eq also proivded.
 111            max_val: The maximum allowed value, inclusive. Pass None if no
 112                maximum value filter should be applied. Defaults to None. Error
 113                thrown if eq also proivded.
 114
 115        Returns:
 116            This object for chaining if desired.
 117        """
 118        self._year = self._create_float_param(eq, min_val, max_val)
 119        return self
 120
 121    def filter_srvy(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 122        max_val: OPT_STR = None) -> 'Query':
 123        """Filter on haul survey short name.
 124
 125        Filter on the short name of the survey in which this observation was
 126        made. Pass None if no filter should be applied. Defaults to None. Note
 127        that common values include: NBS (N Bearing Sea), EBS (SE Bearing Sea),
 128        BSS (Bearing Sea Slope), GOA (Gulf of Alaska), and AI (Aleutian
 129        Islands). Overwrites all prior srvy filters if set on this Query.
 130
 131        Args:
 132            eq: The exact value that must be matched for a record to be
 133                returned. Pass None if no equality filter should be applied.
 134                Error thrown if min_val or max_val also provided.
 135            min_val: The minimum allowed value, inclusive. Pass None if no
 136                minimum value filter should be applied. Defaults to None. Error
 137                thrown if eq also proivded.
 138            max_val: The maximum allowed value, inclusive. Pass None if no
 139                maximum value filter should be applied. Defaults to None. Error
 140                thrown if eq also proivded.
 141
 142        Returns:
 143            This object for chaining if desired.
 144        """
 145        self._srvy = self._create_str_param(eq, min_val, max_val)
 146        return self
 147
 148    def filter_survey(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 149        max_val: OPT_STR = None) -> 'Query':
 150        """Filter on survey long name.
 151
 152        Filter on long form description of the survey in which the observation
 153        was made. Overwrites all prior survey filters if set on this Query.
 154
 155        Args:
 156            eq: The exact value that must be matched for a record to be
 157                returned. Pass None if no equality filter should be applied.
 158                Error thrown if min_val or max_val also provided.
 159            min_val: The minimum allowed value, inclusive. Pass None if no
 160                minimum value filter should be applied. Defaults to None. Error
 161                thrown if eq also proivded.
 162            max_val: The maximum allowed value, inclusive. Pass None if no
 163                maximum value filter should be applied. Defaults to None. Error
 164                thrown if eq also proivded.
 165
 166        Returns:
 167            This object for chaining if desired.
 168        """
 169        self._survey = self._create_str_param(eq, min_val, max_val)
 170        return self
 171
 172    def filter_survey_id(self, eq: OPT_FLOAT = None,
 173        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 174        """Filter on unique numeric ID for the survey.
 175
 176        Filter on unique numeric ID for the survey, overwritting prior survey ID
 177        filters if set on this Query.
 178
 179        Args:
 180            eq: The exact value that must be matched for a record to be
 181                returned. Pass None if no equality filter should be applied.
 182                Error thrown if min_val or max_val also provided.
 183            min_val: The minimum allowed value, inclusive. Pass None if no
 184                minimum value filter should be applied. Defaults to None. Error
 185                thrown if eq also proivded.
 186            max_val: The maximum allowed value, inclusive. Pass None if no
 187                maximum value filter should be applied. Defaults to None. Error
 188                thrown if eq also proivded.
 189
 190        Returns:
 191            This object for chaining if desired.
 192        """
 193        self._survey_id = self._create_float_param(eq, min_val, max_val)
 194        return self
 195
 196    def filter_cruise(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 197        max_val: OPT_FLOAT = None) -> 'Query':
 198        """Filter on cruise ID.
 199
 200        Filter on an ID uniquely identifying the cruise in which the observation
 201        was made. Overwrites all prior cruise filters on this Query.
 202
 203        Args:
 204            eq: The exact value that must be matched for a record to be
 205                returned. Pass None if no equality filter should be applied.
 206                Error thrown if min_val or max_val also provided.
 207            min_val: The minimum allowed value, inclusive. Pass None if no
 208                minimum value filter should be applied. Defaults to None. Error
 209                thrown if eq also proivded.
 210            max_val: The maximum allowed value, inclusive. Pass None if no
 211                maximum value filter should be applied. Defaults to None. Error
 212                thrown if eq also proivded.
 213
 214        Returns:
 215            This object for chaining if desired.
 216        """
 217        self._cruise = self._create_float_param(eq, min_val, max_val)
 218        return self
 219
 220    def filter_haul(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 221        max_val: OPT_FLOAT = None) -> 'Query':
 222        """Filter on haul identifier.
 223
 224        Filter on an ID uniquely identifying the haul in which this observation
 225        was made. Overwrites all prior haul filters on this Query.
 226
 227        Args:
 228            eq: The exact value that must be matched for a record to be
 229                returned. Pass None if no equality filter should be applied.
 230                Error thrown if min_val or max_val also provided.
 231            min_val: The minimum allowed value, inclusive. Pass None if no
 232                minimum value filter should be applied. Defaults to None. Error
 233                thrown if eq also proivded.
 234            max_val: The maximum allowed value, inclusive. Pass None if no
 235                maximum value filter should be applied. Defaults to None. Error
 236                thrown if eq also proivded.
 237
 238        Returns:
 239            This object for chaining if desired.
 240        """
 241        self._haul = self._create_float_param(eq, min_val, max_val)
 242        return self
 243
 244    def filter_stratum(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 245        max_val: OPT_FLOAT = None) -> 'Query':
 246        """Filter on unique ID for statistical area / survey combination.
 247
 248        Filter on unique ID for statistical area / survey combination,
 249        overwritting all prior stratum filters on Query.
 250
 251        Args:
 252            eq: The exact value that must be matched for a record to be
 253                returned. Pass None if no equality filter should be applied.
 254                Error thrown if min_val or max_val also provided.
 255            min_val: The minimum allowed value, inclusive. Pass None if no
 256                minimum value filter should be applied. Defaults to None. Error
 257                thrown if eq also proivded.
 258            max_val: The maximum allowed value, inclusive. Pass None if no
 259                maximum value filter should be applied. Defaults to None. Error
 260                thrown if eq also proivded.
 261
 262        Returns:
 263            This object for chaining if desired.
 264        """
 265        self._stratum = self._create_float_param(eq, min_val, max_val)
 266        return self
 267
 268    def filter_station(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 269        max_val: OPT_STR = None) -> 'Query':
 270        """Filter on station associated with the survey.
 271
 272        Filter on station associated with the survey, overwritting all prior
 273        station filters on this Query.
 274
 275        Args:
 276            eq: The exact value that must be matched for a record to be
 277                returned. Pass None if no equality filter should be applied.
 278                Error thrown if min_val or max_val also provided.
 279            min_val: The minimum allowed value, inclusive. Pass None if no
 280                minimum value filter should be applied. Defaults to None. Error
 281                thrown if eq also proivded.
 282            max_val: The maximum allowed value, inclusive. Pass None if no
 283                maximum value filter should be applied. Defaults to None. Error
 284                thrown if eq also proivded.
 285
 286        Returns:
 287            This object for chaining if desired.
 288        """
 289        self._station = self._create_str_param(eq, min_val, max_val)
 290        return self
 291
 292    def filter_vessel_name(self, eq: STR_PARAM = None,
 293        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 294        """Filter on unique ID describing the vessel that made this observation.
 295
 296        Filter on unique ID describing the vessel that made this observation,
 297        overwritting all prior vessel name filters on this Query.
 298
 299        Args:
 300            eq: The exact value that must be matched for a record to be
 301                returned. Pass None if no equality filter should be applied.
 302                Error thrown if min_val or max_val also provided.
 303            min_val: The minimum allowed value, inclusive. Pass None if no
 304                minimum value filter should be applied. Defaults to None. Error
 305                thrown if eq also proivded.
 306            max_val: The maximum allowed value, inclusive. Pass None if no
 307                maximum value filter should be applied. Defaults to None. Error
 308                thrown if eq also proivded.
 309
 310        Returns:
 311            This object for chaining if desired.
 312        """
 313        self._vessel_name = self._create_str_param(eq, min_val, max_val)
 314        return self
 315
 316    def filter_vessel_id(self, eq: OPT_FLOAT = None,
 317        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 318        """Filter on name of the vessel at the time the observation was made.
 319
 320        Filter on name of the vessel at the time the observation was made,
 321        overwritting all prior vessel ID filters on this Query.
 322
 323        Args:
 324            eq: The exact value that must be matched for a record to be
 325                returned. Pass None if no equality filter should be applied.
 326                Error thrown if min_val or max_val also provided.
 327            min_val: The minimum allowed value, inclusive. Pass None if no
 328                minimum value filter should be applied. Defaults to None. Error
 329                thrown if eq also proivded.
 330            max_val: The maximum allowed value, inclusive. Pass None if no
 331                maximum value filter should be applied. Defaults to None. Error
 332                thrown if eq also proivded.
 333
 334        Returns:
 335            This object for chaining if desired.
 336        """
 337        self._vessel_id = self._create_float_param(eq, min_val, max_val)
 338        return self
 339
 340    def filter_date_time(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 341        max_val: OPT_STR = None) -> 'Query':
 342        """Filter on the date and time of the haul.
 343
 344        Filter on the date and time of the haul as an ISO 8601 string. If given
 345        an ISO 8601 string, will afscgap.convert from ISO 8601 to the API
 346        datetime string format. Similarly, if given a dictionary, all values
 347        matching an ISO 8601 string will be afscgap.converted to the API
 348        datetime string format. Overwrites all prior date time filters on
 349        this Query.
 350
 351        Args:
 352            eq: The exact value that must be matched for a record to be
 353                returned. Pass None if no equality filter should be applied.
 354                Error thrown if min_val or max_val also provided.
 355            min_val: The minimum allowed value, inclusive. Pass None if no
 356                minimum value filter should be applied. Defaults to None. Error
 357                thrown if eq also proivded.
 358            max_val: The maximum allowed value, inclusive. Pass None if no
 359                maximum value filter should be applied. Defaults to None. Error
 360                thrown if eq also proivded.
 361
 362        Returns:
 363            This object for chaining if desired.
 364        """
 365        self._date_time = self._create_str_param(eq, min_val, max_val)
 366        return self
 367
 368    def filter_latitude(self, eq: OPT_FLOAT = None,
 369        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 370        units: str = 'dd') -> 'Query':
 371        """Filter on latitude in decimal degrees associated with the haul.
 372
 373        Filter on latitude in decimal degrees associated with the haul,
 374        overwritting all prior latitude filters on this Query.
 375
 376        Args:
 377            eq: The exact value that must be matched for a record to be
 378                returned. Pass None if no equality filter should be applied.
 379                Error thrown if min_val or max_val also provided.
 380            min_val: The minimum allowed value, inclusive. Pass None if no
 381                minimum value filter should be applied. Defaults to None. Error
 382                thrown if eq also proivded.
 383            max_val: The maximum allowed value, inclusive. Pass None if no
 384                maximum value filter should be applied. Defaults to None. Error
 385                thrown if eq also proivded.
 386            units: The units in which the filter values are provided. Currently
 387                only dd supported.
 388
 389        Returns:
 390            This object for chaining if desired.
 391        """
 392        self._latitude_dd = self._create_float_param(
 393            afscgap.convert.convert(eq, units, 'dd'),
 394            afscgap.convert.convert(min_val, units, 'dd'),
 395            afscgap.convert.convert(max_val, units, 'dd')
 396        )
 397        return self
 398
 399    def filter_longitude(self, eq: OPT_FLOAT = None,
 400        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 401        units: str = 'dd') -> 'Query':
 402        """Filter on longitude in decimal degrees associated with the haul.
 403
 404        Filter on longitude in decimal degrees associated with the haul,
 405        overwritting all prior longitude filters on this Query.
 406
 407        Args:
 408            eq: The exact value that must be matched for a record to be
 409                returned. Pass None if no equality filter should be applied.
 410                Error thrown if min_val or max_val also provided.
 411            min_val: The minimum allowed value, inclusive. Pass None if no
 412                minimum value filter should be applied. Defaults to None. Error
 413                thrown if eq also proivded.
 414            max_val: The maximum allowed value, inclusive. Pass None if no
 415                maximum value filter should be applied. Defaults to None. Error
 416                thrown if eq also proivded.
 417            units: The units in which the filter values are provided. Currently
 418                only dd supported.
 419
 420        Returns:
 421            This object for chaining if desired.
 422        """
 423        self._longitude_dd = self._create_float_param(
 424            afscgap.convert.convert(eq, units, 'dd'),
 425            afscgap.convert.convert(min_val, units, 'dd'),
 426            afscgap.convert.convert(max_val, units, 'dd')
 427        )
 428        return self
 429
 430    def filter_species_code(self, eq: OPT_FLOAT = None,
 431        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
 432        """Filter on unique ID associated with the species observed.
 433
 434        Filter on unique ID associated with the species observed, overwritting
 435        all prior species code filters on this Query.
 436
 437        Args:
 438            eq: The exact value that must be matched for a record to be
 439                returned. Pass None if no equality filter should be applied.
 440                Error thrown if min_val or max_val also provided.
 441            min_val: The minimum allowed value, inclusive. Pass None if no
 442                minimum value filter should be applied. Defaults to None. Error
 443                thrown if eq also proivded.
 444            max_val: The maximum allowed value, inclusive. Pass None if no
 445                maximum value filter should be applied. Defaults to None. Error
 446                thrown if eq also proivded.
 447
 448        Returns:
 449            This object for chaining if desired.
 450        """
 451        self._species_code = self._create_float_param(eq, min_val, max_val)
 452        return self
 453
 454    def filter_common_name(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
 455        max_val: OPT_STR = None) -> 'Query':
 456        """Filter on the "common name" associated with the species observed.
 457
 458        Filter on the "common name" associated with the species observed,
 459        overwritting all prior common name filters on this Query.
 460
 461        Args:
 462            eq: The exact value that must be matched for a record to be
 463                returned. Pass None if no equality filter should be applied.
 464                Error thrown if min_val or max_val also provided.
 465            min_val: The minimum allowed value, inclusive. Pass None if no
 466                minimum value filter should be applied. Defaults to None. Error
 467                thrown if eq also proivded.
 468            max_val: The maximum allowed value, inclusive. Pass None if no
 469                maximum value filter should be applied. Defaults to None. Error
 470                thrown if eq also proivded.
 471
 472        Returns:
 473            This object for chaining if desired.
 474        """
 475        self._common_name = self._create_str_param(eq, min_val, max_val)
 476        return self
 477
 478    def filter_scientific_name(self, eq: STR_PARAM = None,
 479        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 480        """Filter on the "scientific name" associated with the species observed.
 481
 482        Filter on the "scientific name" associated with the species observed,
 483        overwritting all prior scientific name filters on this Query.
 484
 485        Args:
 486            eq: The exact value that must be matched for a record to be
 487                returned. Pass None if no equality filter should be applied.
 488                Error thrown if min_val or max_val also provided.
 489            min_val: The minimum allowed value, inclusive. Pass None if no
 490                minimum value filter should be applied. Defaults to None. Error
 491                thrown if eq also proivded.
 492            max_val: The maximum allowed value, inclusive. Pass None if no
 493                maximum value filter should be applied. Defaults to None. Error
 494                thrown if eq also proivded.
 495
 496        Returns:
 497            This object for chaining if desired.
 498        """
 499        self._scientific_name = self._create_str_param(eq, min_val, max_val)
 500        return self
 501
 502    def filter_taxon_confidence(self, eq: STR_PARAM = None,
 503        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
 504        """Filter on confidence flag regarding ability to identify species.
 505
 506        Filter on confidence flag regarding ability to identify species,
 507        overwritting all taxon confidence filters on this Query.
 508
 509        Args:
 510            eq: The exact value that must be matched for a record to be
 511                returned. Pass None if no equality filter should be applied.
 512                Error thrown if min_val or max_val also provided.
 513            min_val: The minimum allowed value, inclusive. Pass None if no
 514                minimum value filter should be applied. Defaults to None. Error
 515                thrown if eq also proivded.
 516            max_val: The maximum allowed value, inclusive. Pass None if no
 517                maximum value filter should be applied. Defaults to None. Error
 518                thrown if eq also proivded.
 519
 520        Returns:
 521            This object for chaining if desired.
 522        """
 523        self._taxon_confidence = self._create_str_param(eq, min_val, max_val)
 524        return self
 525
 526    def filter_cpue_weight(self, eq: OPT_FLOAT = None,
 527        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 528        units: str = 'kg/ha') -> 'Query':
 529        """Filter on catch per unit effort.
 530
 531        Filter on catch per unit effort as weight divided by net area if
 532        available. Overwrites all prior CPUE weight filters applied to this
 533        Query.
 534
 535        Args:
 536            eq: The exact value that must be matched for a record to be
 537                returned. Pass None if no equality filter should be applied.
 538                Error thrown if min_val or max_val also provided.
 539            min_val: The minimum allowed value, inclusive. Pass None if no
 540                minimum value filter should be applied. Defaults to None. Error
 541                thrown if eq also proivded.
 542            max_val: The maximum allowed value, inclusive. Pass None if no
 543                maximum value filter should be applied. Defaults to None. Error
 544                thrown if eq also proivded.
 545            units: The units for the catch per unit effort provided. Options:
 546                kg/ha, kg/km2, kg1000/km2. Defaults to kg/ha.
 547
 548        Returns:
 549            This object for chaining if desired.
 550        """
 551        param = self._create_float_param(eq, min_val, max_val)
 552
 553        self._cpue_kgha = afscgap.param.EmptyParam()
 554        self._cpue_kgkm2 = afscgap.param.EmptyParam()
 555        self._cpue_kg1000km2 = afscgap.param.EmptyParam()
 556
 557        if units == 'kg/ha':
 558            self._cpue_kgha = param
 559        elif units == 'kg/km2':
 560            self._cpue_kgkm2 = param
 561        elif units == 'kg1000/km2':
 562            self._cpue_kg1000km2 = param
 563        else:
 564            raise RuntimeError('Unrecognized units ' + units)
 565
 566        return self
 567
 568    def filter_cpue_count(self, eq: OPT_FLOAT = None,
 569        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 570        units: str = 'count/ha') -> 'Query':
 571        """Filter catch per unit effort as count over area in hectares.
 572
 573        Filter on catch number divided by net sweep area if available (count /
 574        hectares). Overwrites all prior CPUE count filters applied to this
 575        Query.
 576
 577        Args:
 578            eq: The exact value that must be matched for a record to be
 579                returned. Pass None if no equality filter should be applied.
 580                Error thrown if min_val or max_val also provided.
 581            min_val: The minimum allowed value, inclusive. Pass None if no
 582                minimum value filter should be applied. Defaults to None. Error
 583                thrown if eq also proivded.
 584            max_val: The maximum allowed value, inclusive. Pass None if no
 585                maximum value filter should be applied. Defaults to None. Error
 586                thrown if eq also proivded.
 587            units: The units for the given catch per unit effort. Options:
 588                count/ha, count/km2, and count1000/km2. Defaults to count/ha.
 589
 590        Returns:
 591            This object for chaining if desired.
 592        """
 593        param = self._create_float_param(eq, min_val, max_val)
 594
 595        self._cpue_noha = afscgap.param.EmptyParam()
 596        self._cpue_nokm2 = afscgap.param.EmptyParam()
 597        self._cpue_no1000km2 = afscgap.param.EmptyParam()
 598
 599        if units == 'count/ha':
 600            self._cpue_noha = param
 601        elif units == 'count/km2':
 602            self._cpue_nokm2 = param
 603        elif units == 'count1000/km2':
 604            self._cpue_no1000km2 = param
 605        else:
 606            raise RuntimeError('Unrecognized units ' + units)
 607
 608        return self
 609
 610    def filter_weight(self, eq: OPT_FLOAT = None,
 611        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 612        units: str = 'kg') -> 'Query':
 613        """Filter on taxon weight (kg) if available.
 614
 615        Filter on taxon weight (kg) if available, overwrites all prior weight
 616        filters applied to this Query.
 617
 618        Args:
 619            eq: The exact value that must be matched for a record to be
 620                returned. Pass None if no equality filter should be applied.
 621                Error thrown if min_val or max_val also provided.
 622            min_val: The minimum allowed value, inclusive. Pass None if no
 623                minimum value filter should be applied. Defaults to None. Error
 624                thrown if eq also proivded.
 625            max_val: The maximum allowed value, inclusive. Pass None if no
 626                maximum value filter should be applied. Defaults to None. Error
 627                thrown if eq also proivded.
 628            units: The units in which the weight are given. Options are
 629                g, kg for grams and kilograms respectively. Deafults to kg.
 630
 631        Returns:
 632            This object for chaining if desired.
 633        """
 634        self._weight_kg = self._create_float_param(
 635            afscgap.convert.convert(eq, units, 'kg'),
 636            afscgap.convert.convert(min_val, units, 'kg'),
 637            afscgap.convert.convert(max_val, units, 'kg')
 638        )
 639        return self
 640
 641    def filter_count(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 642        max_val: OPT_FLOAT = None) -> 'Query':
 643        """Filter on total number of organism individuals in haul.
 644
 645        Filter on total number of organism individuals in haul, overwrites all
 646        prior count filters applied to this Query.
 647
 648        Args:
 649            eq: The exact value that must be matched for a record to be
 650                returned. Pass None if no equality filter should be applied.
 651                Error thrown if min_val or max_val also provided.
 652            min_val: The minimum allowed value, inclusive. Pass None if no
 653                minimum value filter should be applied. Defaults to None. Error
 654                thrown if eq also proivded.
 655            max_val: The maximum allowed value, inclusive. Pass None if no
 656                maximum value filter should be applied. Defaults to None. Error
 657                thrown if eq also proivded.
 658
 659        Returns:
 660            This object for chaining if desired.
 661        """
 662        self._count = self._create_float_param(eq, min_val, max_val)
 663        return self
 664
 665    def filter_bottom_temperature(self, eq: OPT_FLOAT = None,
 666        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 667        units: str = 'c') -> 'Query':
 668        """Filter on bottom temperature.
 669
 670        Filter on bottom temperature associated with observation if available in
 671        the units given. Overwrites all prior bottom temperature filters applied
 672        to this Query.
 673
 674        Args:
 675            eq: The exact value that must be matched for a record to be
 676                returned. Pass None if no equality filter should be applied.
 677                Error thrown if min_val or max_val also provided.
 678            min_val: The minimum allowed value, inclusive. Pass None if no
 679                minimum value filter should be applied. Defaults to None. Error
 680                thrown if eq also proivded.
 681            max_val: The maximum allowed value, inclusive. Pass None if no
 682                maximum value filter should be applied. Defaults to None. Error
 683                thrown if eq also proivded.
 684            units: The units in which the temperature filter values are given.
 685                Options: c or f for Celcius and Fahrenheit respectively.
 686                Defaults to c.
 687
 688        Returns:
 689            This object for chaining if desired.
 690        """
 691        self._bottom_temperature_c = self._create_float_param(
 692            afscgap.convert.convert(eq, units, 'c'),
 693            afscgap.convert.convert(min_val, units, 'c'),
 694            afscgap.convert.convert(max_val, units, 'c')
 695        )
 696        return self
 697
 698    def filter_surface_temperature(self, eq: OPT_FLOAT = None,
 699        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 700        units: str = 'c') -> 'Query':
 701        """Filter on surface temperature.
 702
 703        Filter on surface temperature associated with observation if available
 704        in the units given. Overwrites all prior bottom temperature filters
 705        applied to this Query.
 706
 707        Args:
 708            eq: The exact value that must be matched for a record to be
 709                returned. Pass None if no equality filter should be applied.
 710                Error thrown if min_val or max_val also provided.
 711            min_val: The minimum allowed value, inclusive. Pass None if no
 712                minimum value filter should be applied. Defaults to None. Error
 713                thrown if eq also proivded.
 714            max_val: The maximum allowed value, inclusive. Pass None if no
 715                maximum value filter should be applied. Defaults to None. Error
 716                thrown if eq also proivded.
 717            units: The units in which the temperature filter values are given.
 718                Options: c or f for Celcius and Fahrenheit respectively.
 719                Defaults to c.
 720
 721        Returns:
 722            This object for chaining if desired.
 723        """
 724        self._surface_temperature_c = self._create_float_param(
 725            afscgap.convert.convert(eq, units, 'c'),
 726            afscgap.convert.convert(min_val, units, 'c'),
 727            afscgap.convert.convert(max_val, units, 'c')
 728        )
 729        return self
 730
 731    def filter_depth(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 732        max_val: OPT_FLOAT = None, units: str = 'm') -> 'Query':
 733        """Filter on depth of the bottom in meters.
 734
 735        Filter on depth of the bottom in meters, overwrites all prior depth
 736        filters applied to this Query.
 737
 738        Args:
 739            eq: The exact value that must be matched for a record to be
 740                returned. Pass None if no equality filter should be applied.
 741                Error thrown if min_val or max_val also provided.
 742            min_val: The minimum allowed value, inclusive. Pass None if no
 743                minimum value filter should be applied. Defaults to None. Error
 744                thrown if eq also proivded.
 745            max_val: The maximum allowed value, inclusive. Pass None if no
 746                maximum value filter should be applied. Defaults to None. Error
 747                thrown if eq also proivded.
 748            units: The units in which the distance are given. Options:
 749                m or km for meters and kilometers respectively. Defaults to m.
 750
 751        Returns:
 752            This object for chaining if desired.
 753        """
 754        self._depth_m = self._create_float_param(
 755            afscgap.convert.convert(eq, units, 'm'),
 756            afscgap.convert.convert(min_val, units, 'm'),
 757            afscgap.convert.convert(max_val, units, 'm')
 758        )
 759        return self
 760
 761    def filter_distance_fished(self, eq: OPT_FLOAT = None,
 762        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 763        units: str = 'm') -> 'Query':
 764        """Filter on distance of the net fished.
 765
 766        Filter on distance of the net fished, overwritting prior distance fished
 767        filters applied to this Query.
 768
 769        Args:
 770            eq: The exact value that must be matched for a record to be
 771                returned. Pass None if no equality filter should be applied.
 772                Error thrown if min_val or max_val also provided.
 773            min_val: The minimum allowed value, inclusive. Pass None if no
 774                minimum value filter should be applied. Defaults to None. Error
 775                thrown if eq also proivded.
 776            max_val: The maximum allowed value, inclusive. Pass None if no
 777                maximum value filter should be applied. Defaults to None. Error
 778                thrown if eq also proivded.
 779            units: The units in which the distance values are given. Options:
 780                m or km for meters and kilometers respectively. Defaults to m.
 781
 782        Returns:
 783            This object for chaining if desired.
 784        """
 785        def convert_to_km(target, units):
 786            return afscgap.convert.convert(target, units, 'km')
 787
 788        self._distance_fished_km = self._create_float_param(
 789            convert_to_km(eq, units),
 790            convert_to_km(min_val, units),
 791            convert_to_km(max_val, units)
 792        )
 793        return self
 794
 795    def filter_net_width(self, eq: OPT_FLOAT = None,
 796        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 797        units: str = 'm') -> 'Query':
 798        """Filter on distance of the net fished.
 799
 800        Filter on distance of the net fished, overwritting prior net width
 801        filters applied to this Query.
 802
 803        Args:
 804            eq: The exact value that must be matched for a record to be
 805                returned. Pass None if no equality filter should be applied.
 806                Error thrown if min_val or max_val also provided.
 807            min_val: The minimum allowed value, inclusive. Pass None if no
 808                minimum value filter should be applied. Defaults to None. Error
 809                thrown if eq also proivded.
 810            max_val: The maximum allowed value, inclusive. Pass None if no
 811                maximum value filter should be applied. Defaults to None. Error
 812                thrown if eq also proivded.
 813            units: The units in which the distance should be returned. Options:
 814                m or km for meters and kilometers respectively. Defaults to m.
 815
 816        Returns:
 817            This object for chaining if desired.
 818        """
 819        self._net_width_m = self._create_float_param(
 820            afscgap.convert.convert(eq, units, 'm'),
 821            afscgap.convert.convert(min_val, units, 'm'),
 822            afscgap.convert.convert(max_val, units, 'm')
 823        )
 824        return self
 825
 826    def filter_net_height(self, eq: OPT_FLOAT = None,
 827        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 828        units: str = 'm') -> 'Query':
 829        """Filter on height of the net fished.
 830
 831        Filter on height of the net fished, overwritting prior net height
 832        filters applied to this Query.
 833
 834        Args:
 835            eq: The exact value that must be matched for a record to be
 836                returned. Pass None if no equality filter should be applied.
 837                Error thrown if min_val or max_val also provided.
 838            min_val: The minimum allowed value, inclusive. Pass None if no
 839                minimum value filter should be applied. Defaults to None. Error
 840                thrown if eq also proivded.
 841            max_val: The maximum allowed value, inclusive. Pass None if no
 842                maximum value filter should be applied. Defaults to None. Error
 843                thrown if eq also proivded.
 844            units: The units in which the distance should be returned. Options:
 845                m or km for meters and kilometers respectively. Defaults to m.
 846
 847        Returns:
 848            This object for chaining if desired.
 849        """
 850        self._net_height_m = self._create_float_param(
 851            afscgap.convert.convert(eq, units, 'm'),
 852            afscgap.convert.convert(min_val, units, 'm'),
 853            afscgap.convert.convert(max_val, units, 'm')
 854        )
 855        return self
 856
 857    def filter_area_swept(self, eq: OPT_FLOAT = None,
 858        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 859        units: str = 'm') -> 'Query':
 860        """Filter on area covered by the net while fishing.
 861
 862        Filter on area covered by the net while fishing, overwritting prior
 863        area swept filters applied to this Query.
 864
 865        Args:
 866            eq: The exact value that must be matched for a record to be
 867                returned. Pass None if no equality filter should be applied.
 868                Error thrown if min_val or max_val also provided.
 869            min_val: The minimum allowed value, inclusive. Pass None if no
 870                minimum value filter should be applied. Defaults to None. Error
 871                thrown if eq also proivded.
 872            max_val: The maximum allowed value, inclusive. Pass None if no
 873                maximum value filter should be applied. Defaults to None. Error
 874                thrown if eq also proivded.
 875            units: The units in which the area should be returned. Options:
 876                ha, m2, km2. Defaults to ha.
 877
 878        Returns:
 879            This object for chaining if desired.
 880        """
 881        self._area_swept_ha = self._create_float_param(
 882            afscgap.convert.convert(eq, units, 'ha'),
 883            afscgap.convert.convert(min_val, units, 'ha'),
 884            afscgap.convert.convert(max_val, units, 'ha')
 885        )
 886        return self
 887
 888    def filter_duration(self, eq: OPT_FLOAT = None,
 889        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
 890        units: str = 'hr') -> 'Query':
 891        """Filter on duration of the haul.
 892
 893        Filter on duration of the haul, ovewritting all prior duration filters
 894        applied to this Query.
 895
 896        Args:
 897            eq: The exact value that must be matched for a record to be
 898                returned. Pass None if no equality filter should be applied.
 899                Error thrown if min_val or max_val also provided.
 900            min_val: The minimum allowed value, inclusive. Pass None if no
 901                minimum value filter should be applied. Defaults to None. Error
 902                thrown if eq also proivded.
 903            max_val: The maximum allowed value, inclusive. Pass None if no
 904                maximum value filter should be applied. Defaults to None. Error
 905                thrown if eq also proivded.
 906            units: The units in which the duration should be returned. Options:
 907                day, hr, min. Defaults to hr.
 908
 909        Returns:
 910            This object for chaining if desired.
 911        """
 912        self._duration_hr = self._create_float_param(
 913            afscgap.convert.convert(eq, units, 'hr'),
 914            afscgap.convert.convert(min_val, units, 'hr'),
 915            afscgap.convert.convert(max_val, units, 'hr')
 916        )
 917        return self
 918
 919    def set_limit(self, limit: OPT_INT) -> 'Query':
 920        """Set the max number of results.
 921
 922        Set the max number of results, overwritting prior limit settings on this
 923        Query.
 924
 925        Args:
 926            limit: The maximum number of results to retrieve per HTTP request.
 927                If None or not provided, will use API's default.
 928
 929        Returns:
 930            This object for chaining if desired.
 931        """
 932        self._limit = limit
 933        return self
 934
 935    def set_filter_incomplete(self, filter_incomplete: bool) -> 'Query':
 936        """Indicate if incomplete records should be filtered out.
 937
 938        Indicate if incomplete records should be filtered out, overwritting
 939        prior incomplete filter settings on this Query.
 940
 941        Args:
 942            filter_incomplete: Flag indicating if "incomplete" records should be
 943                filtered. If true, "incomplete" records are silently filtered
 944                from the results, putting them in the invalid records queue. If
 945                false, they are included and their is_complete() will return
 946                false. Defaults to false.
 947
 948        Returns:
 949            This object for chaining if desired.
 950        """
 951        self._filter_incomplete = filter_incomplete
 952        return self
 953
 954    def set_presence_only(self, presence_only: bool) -> 'Query':
 955        """Indicate if zero catch inference should be enabled.
 956
 957        Indicate if zero catch inference should be enabled, overwritting prior
 958        abscence / zero catch data settings on this Query.
 959
 960        Args:
 961            presence_only: Flag indicating if abscence / zero catch data should
 962                be inferred. If false, will run abscence data inference. If
 963                true, will return presence only data as returned by the NOAA API
 964                service. Defaults to true.
 965
 966        Returns:
 967            This object for chaining if desired.
 968        """
 969        self._presence_only = presence_only
 970        return self
 971
 972    def set_suppress_large_warning(self, supress: bool) -> 'Query':
 973        """Indicate if the large results warning should be supressed.
 974
 975        Indicate if the large results warning should be supressed, overwritting
 976        prior large results warning supressions settings on this Query.
 977
 978        Args:
 979            suppress_large_warning: Indicate if the library should warn when an
 980                operation may consume a large amount of memory. If true, the
 981                warning will not be emitted. Defaults to true.
 982
 983        Returns:
 984            This object for chaining if desired.
 985        """
 986        self._suppress_large_warning = supress
 987        return self
 988
 989    def set_warn_function(self, warn_function: WARN_FUNCTION) -> 'Query':
 990        """Indicate how warnings should be emitted.
 991
 992        Indicate how warnings should be emitted, overwritting the prior warning
 993        function settings on this Query.
 994
 995        Args:
 996            warn_function: Function to call with a message describing warnings
 997                encountered. If None, will use warnings.warn. Defaults to None.
 998
 999        Returns:
1000            This object for chaining if desired.
1001        """
1002        self._warn_function = warn_function
1003        return self
1004
1005    def execute(self) -> afscgap.cursor.Cursor:
1006        """Execute the query built up in this object.
1007
1008        Execute the query built up in this object using its current state. Note
1009        that later changes to this builder will not impact prior returned
1010        Cursors from execute.
1011
1012        Returns:
1013            Cursor to manage HTTP requests and query results.
1014        """
1015        params_dict = {
1016            'year': self._year,
1017            'srvy': self._srvy,
1018            'survey': self._survey,
1019            'survey_id': self._survey_id,
1020            'cruise': self._cruise,
1021            'haul': self._haul,
1022            'stratum': self._stratum,
1023            'station': self._station,
1024            'vessel_name': self._vessel_name,
1025            'vessel_id': self._vessel_id,
1026            'date_time': self._date_time,
1027            'latitude_dd': self._latitude_dd,
1028            'longitude_dd': self._longitude_dd,
1029            'species_code': self._species_code,
1030            'common_name': self._common_name,
1031            'scientific_name': self._scientific_name,
1032            'taxon_confidence': self._taxon_confidence,
1033            'cpue_kgha': self._cpue_kgha,
1034            'cpue_kgkm2': self._cpue_kgkm2,
1035            'cpue_kg1000km2': self._cpue_kg1000km2,
1036            'cpue_noha': self._cpue_noha,
1037            'cpue_nokm2': self._cpue_nokm2,
1038            'cpue_no1000km2': self._cpue_no1000km2,
1039            'weight_kg': self._weight_kg,
1040            'count': self._count,
1041            'bottom_temperature_c': self._bottom_temperature_c,
1042            'surface_temperature_c': self._surface_temperature_c,
1043            'depth_m': self._depth_m,
1044            'distance_fished_km': self._distance_fished_km,
1045            'net_width_m': self._net_width_m,
1046            'net_height_m': self._net_height_m,
1047            'area_swept_ha': self._area_swept_ha,
1048            'duration_hr': self._duration_hr
1049        }
1050
1051        meta_params = afscgap.flat_model.ExecuteMetaParams(
1052            self._base_url if self._base_url else DEFAULT_URL,
1053            self._requestor,
1054            self._limit,
1055            self._filter_incomplete,
1056            self._presence_only,
1057            self._suppress_large_warning,
1058            self._warn_function
1059        )
1060
1061        return afscgap.flat.execute(params_dict, meta_params)
1062
1063    def _create_str_param(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
1064        max_val: OPT_STR = None) -> afscgap.param.Param:
1065        """Create a new string parameter.
1066
1067        Args:
1068            eq: The exact value that must be matched for a record to be
1069                returned. Pass None if no equality filter should be applied.
1070                Error thrown if min_val or max_val also provided.
1071            min_val: The minimum allowed value, inclusive. Pass None if no
1072                minimum value filter should be applied. Defaults to None. Error
1073                thrown if eq also proivded.
1074            max_val: The maximum allowed value, inclusive. Pass None if no
1075                maximum value filter should be applied. Defaults to None. Error
1076                thrown if eq also proivded.
1077
1078        Returns:
1079            Newly initalized parameter.
1080        """
1081        param_type = self._get_param_type(eq, min_val, max_val)
1082        strategy = {
1083            'empty': lambda: afscgap.param.EmptyParam(),
1084            'equals': lambda: afscgap.param.StrEqualsParam(eq),  # type: ignore
1085            'range': lambda: afscgap.param.StrRangeParam(min_val, max_val)  # type: ignore
1086        }[param_type]
1087        return strategy()  # type: ignore
1088
1089    def _create_float_param(self, eq: OPT_FLOAT = None,
1090        min_val: OPT_FLOAT = None,
1091        max_val: OPT_FLOAT = None) -> afscgap.param.Param:
1092        """Create a new float parameter.
1093
1094        Args:
1095            eq: The exact value that must be matched for a record to be
1096                returned. Pass None if no equality filter should be applied.
1097                Error thrown if min_val or max_val also provided.
1098            min_val: The minimum allowed value, inclusive. Pass None if no
1099                minimum value filter should be applied. Defaults to None. Error
1100                thrown if eq also proivded.
1101            max_val: The maximum allowed value, inclusive. Pass None if no
1102                maximum value filter should be applied. Defaults to None. Error
1103                thrown if eq also proivded.
1104
1105        Returns:
1106            Newly initalized parameter.
1107        """
1108        param_type = self._get_param_type(eq, min_val, max_val)
1109        strategy = {
1110            'empty': lambda: afscgap.param.EmptyParam(),
1111            'equals': lambda: afscgap.param.FloatEqualsParam(eq),    # type: ignore
1112            'range': lambda: afscgap.param.FloatRangeParam(min_val, max_val)   # type: ignore
1113        }[param_type]
1114        return strategy()  # type: ignore
1115
1116    def _create_int_param(self, eq: INT_PARAM = None, min_val: OPT_INT = None,
1117        max_val: OPT_INT = None) -> afscgap.param.Param:
1118        """Create a new int parameter.
1119
1120        Args:
1121            eq: The exact value that must be matched for a record to be
1122                returned. Pass None if no equality filter should be applied.
1123                Error thrown if min_val or max_val also provided.
1124            min_val: The minimum allowed value, inclusive. Pass None if no
1125                minimum value filter should be applied. Defaults to None. Error
1126                thrown if eq also proivded.
1127            max_val: The maximum allowed value, inclusive. Pass None if no
1128                maximum value filter should be applied. Defaults to None. Error
1129                thrown if eq also proivded.
1130
1131        Returns:
1132            Newly initalized parameter.
1133        """
1134        param_type = self._get_param_type(eq, min_val, max_val)
1135        strategy = {
1136            'empty': lambda: afscgap.param.EmptyParam(),
1137            'equals': lambda: afscgap.param.IntEqualsParam(eq),  # type: ignore
1138            'range': lambda: afscgap.param.IntRangeParam(min_val, max_val)  # type: ignore
1139        }[param_type]
1140        return strategy()  # type: ignore
1141
1142    def _get_param_type(self, eq, min_val, max_val) -> str:
1143        """Determine how the parameter should be interpreted.
1144
1145        Args:
1146            eq: The value for equality or None if no equals filter.
1147            min_val: The minimum value or None if no minimum filter.
1148            max_val: The maximum value or None if no maximum filter.
1149
1150        Returns:
1151            One of the following as a string: empty, equals, range.
1152        """
1153        if eq is None:
1154            if min_val is None and max_val is None:
1155                return 'empty'
1156            else:
1157                return 'range'
1158        else:
1159            if min_val is not None or max_val is not None:
1160                raise RuntimeError('Both range and equality filters provided.')
1161            else:
1162                return 'equals'

Entrypoint for the AFSC GAP Python library.

Facade for executing queries against AFSC GAP and builder to create those queries.

Query( base_url: Optional[str] = None, requestor: Optional[Callable[[str], requests.models.Response]] = None)
41    def __init__(self, base_url: OPT_STR = None, requestor: OPT_REQUESTOR = None):
42        """Create a new Query.
43
44        Args:
45            base_url: The URL at which the flat files can be found. If None, will use
46                default. See afscgap.DEFAULT_URL.
47            requestor: Strategy to use for making HTTP requests. If None, will
48                use a default as defined by afscgap.client.Cursor.
49        """
50        # URLs for data
51        self._base_url = base_url
52        self._requestor = requestor
53
54        # Filter parameters
55        self._year: afscgap.param.Param = afscgap.param.EmptyParam()
56        self._srvy: afscgap.param.Param = afscgap.param.EmptyParam()
57        self._survey: afscgap.param.Param = afscgap.param.EmptyParam()
58        self._survey_id: afscgap.param.Param = afscgap.param.EmptyParam()
59        self._cruise: afscgap.param.Param = afscgap.param.EmptyParam()
60        self._haul: afscgap.param.Param = afscgap.param.EmptyParam()
61        self._stratum: afscgap.param.Param = afscgap.param.EmptyParam()
62        self._station: afscgap.param.Param = afscgap.param.EmptyParam()
63        self._vessel_name: afscgap.param.Param = afscgap.param.EmptyParam()
64        self._vessel_id: afscgap.param.Param = afscgap.param.EmptyParam()
65        self._date_time: afscgap.param.Param = afscgap.param.EmptyParam()
66        self._latitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
67        self._longitude_dd: afscgap.param.Param = afscgap.param.EmptyParam()
68        self._species_code: afscgap.param.Param = afscgap.param.EmptyParam()
69        self._common_name: afscgap.param.Param = afscgap.param.EmptyParam()
70        self._scientific_name: afscgap.param.Param = afscgap.param.EmptyParam()
71        self._taxon_confidence: afscgap.param.Param = afscgap.param.EmptyParam()
72        self._cpue_kgha: afscgap.param.Param = afscgap.param.EmptyParam()
73        self._cpue_kgkm2: afscgap.param.Param = afscgap.param.EmptyParam()
74        self._cpue_kg1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
75        self._cpue_noha: afscgap.param.Param = afscgap.param.EmptyParam()
76        self._cpue_nokm2: afscgap.param.Param = afscgap.param.EmptyParam()
77        self._cpue_no1000km2: afscgap.param.Param = afscgap.param.EmptyParam()
78        self._weight_kg: afscgap.param.Param = afscgap.param.EmptyParam()
79        self._count: afscgap.param.Param = afscgap.param.EmptyParam()
80        self._bottom_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
81        self._surface_temperature_c: afscgap.param.Param = afscgap.param.EmptyParam()
82        self._depth_m: afscgap.param.Param = afscgap.param.EmptyParam()
83        self._distance_fished_km: afscgap.param.Param = afscgap.param.EmptyParam()
84        self._net_width_m: afscgap.param.Param = afscgap.param.EmptyParam()
85        self._net_height_m: afscgap.param.Param = afscgap.param.EmptyParam()
86        self._area_swept_ha: afscgap.param.Param = afscgap.param.EmptyParam()
87        self._duration_hr: afscgap.param.Param = afscgap.param.EmptyParam()
88
89        # Query pararmeters
90        self._limit: OPT_INT = None
91        self._filter_incomplete: bool = False
92        self._presence_only: bool = False
93        self._suppress_large_warning: bool = False
94        self._warn_function: WARN_FUNCTION = None

Create a new Query.

Arguments:
  • base_url: The URL at which the flat files can be found. If None, will use default. See afscgap.DEFAULT_URL.
  • requestor: Strategy to use for making HTTP requests. If None, will use a default as defined by afscgap.client.Cursor.
def filter_year( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
 96    def filter_year(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
 97        max_val: OPT_FLOAT = None) -> 'Query':
 98        """Filter on year for the survey in which this observation was made.
 99
100        Filter on year for the survey in which this observation was made,
101        ovewritting all prior year filters on this Query if one was previously
102        set.
103
104        Args:
105            eq: The exact value that must be matched for a record to be
106                returned. Pass None if no equality filter should be applied.
107                Error thrown if min_val or max_val also provided.
108            min_val: The minimum allowed value, inclusive. Pass None if no
109                minimum value filter should be applied. Defaults to None. Error
110                thrown if eq also proivded.
111            max_val: The maximum allowed value, inclusive. Pass None if no
112                maximum value filter should be applied. Defaults to None. Error
113                thrown if eq also proivded.
114
115        Returns:
116            This object for chaining if desired.
117        """
118        self._year = self._create_float_param(eq, min_val, max_val)
119        return self

Filter on year for the survey in which this observation was made.

Filter on year for the survey in which this observation was made, ovewritting all prior year filters on this Query if one was previously set.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_srvy( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
121    def filter_srvy(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
122        max_val: OPT_STR = None) -> 'Query':
123        """Filter on haul survey short name.
124
125        Filter on the short name of the survey in which this observation was
126        made. Pass None if no filter should be applied. Defaults to None. Note
127        that common values include: NBS (N Bearing Sea), EBS (SE Bearing Sea),
128        BSS (Bearing Sea Slope), GOA (Gulf of Alaska), and AI (Aleutian
129        Islands). Overwrites all prior srvy filters if set on this Query.
130
131        Args:
132            eq: The exact value that must be matched for a record to be
133                returned. Pass None if no equality filter should be applied.
134                Error thrown if min_val or max_val also provided.
135            min_val: The minimum allowed value, inclusive. Pass None if no
136                minimum value filter should be applied. Defaults to None. Error
137                thrown if eq also proivded.
138            max_val: The maximum allowed value, inclusive. Pass None if no
139                maximum value filter should be applied. Defaults to None. Error
140                thrown if eq also proivded.
141
142        Returns:
143            This object for chaining if desired.
144        """
145        self._srvy = self._create_str_param(eq, min_val, max_val)
146        return self

Filter on haul survey short name.

Filter on the short name of the survey in which this observation was made. Pass None if no filter should be applied. Defaults to None. Note that common values include: NBS (N Bearing Sea), EBS (SE Bearing Sea), BSS (Bearing Sea Slope), GOA (Gulf of Alaska), and AI (Aleutian Islands). Overwrites all prior srvy filters if set on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_survey( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
148    def filter_survey(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
149        max_val: OPT_STR = None) -> 'Query':
150        """Filter on survey long name.
151
152        Filter on long form description of the survey in which the observation
153        was made. Overwrites all prior survey filters if set on this Query.
154
155        Args:
156            eq: The exact value that must be matched for a record to be
157                returned. Pass None if no equality filter should be applied.
158                Error thrown if min_val or max_val also provided.
159            min_val: The minimum allowed value, inclusive. Pass None if no
160                minimum value filter should be applied. Defaults to None. Error
161                thrown if eq also proivded.
162            max_val: The maximum allowed value, inclusive. Pass None if no
163                maximum value filter should be applied. Defaults to None. Error
164                thrown if eq also proivded.
165
166        Returns:
167            This object for chaining if desired.
168        """
169        self._survey = self._create_str_param(eq, min_val, max_val)
170        return self

Filter on survey long name.

Filter on long form description of the survey in which the observation was made. Overwrites all prior survey filters if set on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_survey_id( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
172    def filter_survey_id(self, eq: OPT_FLOAT = None,
173        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
174        """Filter on unique numeric ID for the survey.
175
176        Filter on unique numeric ID for the survey, overwritting prior survey ID
177        filters if set on this Query.
178
179        Args:
180            eq: The exact value that must be matched for a record to be
181                returned. Pass None if no equality filter should be applied.
182                Error thrown if min_val or max_val also provided.
183            min_val: The minimum allowed value, inclusive. Pass None if no
184                minimum value filter should be applied. Defaults to None. Error
185                thrown if eq also proivded.
186            max_val: The maximum allowed value, inclusive. Pass None if no
187                maximum value filter should be applied. Defaults to None. Error
188                thrown if eq also proivded.
189
190        Returns:
191            This object for chaining if desired.
192        """
193        self._survey_id = self._create_float_param(eq, min_val, max_val)
194        return self

Filter on unique numeric ID for the survey.

Filter on unique numeric ID for the survey, overwritting prior survey ID filters if set on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_cruise( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
196    def filter_cruise(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
197        max_val: OPT_FLOAT = None) -> 'Query':
198        """Filter on cruise ID.
199
200        Filter on an ID uniquely identifying the cruise in which the observation
201        was made. Overwrites all prior cruise filters on this Query.
202
203        Args:
204            eq: The exact value that must be matched for a record to be
205                returned. Pass None if no equality filter should be applied.
206                Error thrown if min_val or max_val also provided.
207            min_val: The minimum allowed value, inclusive. Pass None if no
208                minimum value filter should be applied. Defaults to None. Error
209                thrown if eq also proivded.
210            max_val: The maximum allowed value, inclusive. Pass None if no
211                maximum value filter should be applied. Defaults to None. Error
212                thrown if eq also proivded.
213
214        Returns:
215            This object for chaining if desired.
216        """
217        self._cruise = self._create_float_param(eq, min_val, max_val)
218        return self

Filter on cruise ID.

Filter on an ID uniquely identifying the cruise in which the observation was made. Overwrites all prior cruise filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_haul( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
220    def filter_haul(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
221        max_val: OPT_FLOAT = None) -> 'Query':
222        """Filter on haul identifier.
223
224        Filter on an ID uniquely identifying the haul in which this observation
225        was made. Overwrites all prior haul filters on this Query.
226
227        Args:
228            eq: The exact value that must be matched for a record to be
229                returned. Pass None if no equality filter should be applied.
230                Error thrown if min_val or max_val also provided.
231            min_val: The minimum allowed value, inclusive. Pass None if no
232                minimum value filter should be applied. Defaults to None. Error
233                thrown if eq also proivded.
234            max_val: The maximum allowed value, inclusive. Pass None if no
235                maximum value filter should be applied. Defaults to None. Error
236                thrown if eq also proivded.
237
238        Returns:
239            This object for chaining if desired.
240        """
241        self._haul = self._create_float_param(eq, min_val, max_val)
242        return self

Filter on haul identifier.

Filter on an ID uniquely identifying the haul in which this observation was made. Overwrites all prior haul filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_stratum( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
244    def filter_stratum(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
245        max_val: OPT_FLOAT = None) -> 'Query':
246        """Filter on unique ID for statistical area / survey combination.
247
248        Filter on unique ID for statistical area / survey combination,
249        overwritting all prior stratum filters on Query.
250
251        Args:
252            eq: The exact value that must be matched for a record to be
253                returned. Pass None if no equality filter should be applied.
254                Error thrown if min_val or max_val also provided.
255            min_val: The minimum allowed value, inclusive. Pass None if no
256                minimum value filter should be applied. Defaults to None. Error
257                thrown if eq also proivded.
258            max_val: The maximum allowed value, inclusive. Pass None if no
259                maximum value filter should be applied. Defaults to None. Error
260                thrown if eq also proivded.
261
262        Returns:
263            This object for chaining if desired.
264        """
265        self._stratum = self._create_float_param(eq, min_val, max_val)
266        return self

Filter on unique ID for statistical area / survey combination.

Filter on unique ID for statistical area / survey combination, overwritting all prior stratum filters on Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_station( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
268    def filter_station(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
269        max_val: OPT_STR = None) -> 'Query':
270        """Filter on station associated with the survey.
271
272        Filter on station associated with the survey, overwritting all prior
273        station filters on this Query.
274
275        Args:
276            eq: The exact value that must be matched for a record to be
277                returned. Pass None if no equality filter should be applied.
278                Error thrown if min_val or max_val also provided.
279            min_val: The minimum allowed value, inclusive. Pass None if no
280                minimum value filter should be applied. Defaults to None. Error
281                thrown if eq also proivded.
282            max_val: The maximum allowed value, inclusive. Pass None if no
283                maximum value filter should be applied. Defaults to None. Error
284                thrown if eq also proivded.
285
286        Returns:
287            This object for chaining if desired.
288        """
289        self._station = self._create_str_param(eq, min_val, max_val)
290        return self

Filter on station associated with the survey.

Filter on station associated with the survey, overwritting all prior station filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_vessel_name( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
292    def filter_vessel_name(self, eq: STR_PARAM = None,
293        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
294        """Filter on unique ID describing the vessel that made this observation.
295
296        Filter on unique ID describing the vessel that made this observation,
297        overwritting all prior vessel name filters on this Query.
298
299        Args:
300            eq: The exact value that must be matched for a record to be
301                returned. Pass None if no equality filter should be applied.
302                Error thrown if min_val or max_val also provided.
303            min_val: The minimum allowed value, inclusive. Pass None if no
304                minimum value filter should be applied. Defaults to None. Error
305                thrown if eq also proivded.
306            max_val: The maximum allowed value, inclusive. Pass None if no
307                maximum value filter should be applied. Defaults to None. Error
308                thrown if eq also proivded.
309
310        Returns:
311            This object for chaining if desired.
312        """
313        self._vessel_name = self._create_str_param(eq, min_val, max_val)
314        return self

Filter on unique ID describing the vessel that made this observation.

Filter on unique ID describing the vessel that made this observation, overwritting all prior vessel name filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_vessel_id( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
316    def filter_vessel_id(self, eq: OPT_FLOAT = None,
317        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
318        """Filter on name of the vessel at the time the observation was made.
319
320        Filter on name of the vessel at the time the observation was made,
321        overwritting all prior vessel ID filters on this Query.
322
323        Args:
324            eq: The exact value that must be matched for a record to be
325                returned. Pass None if no equality filter should be applied.
326                Error thrown if min_val or max_val also provided.
327            min_val: The minimum allowed value, inclusive. Pass None if no
328                minimum value filter should be applied. Defaults to None. Error
329                thrown if eq also proivded.
330            max_val: The maximum allowed value, inclusive. Pass None if no
331                maximum value filter should be applied. Defaults to None. Error
332                thrown if eq also proivded.
333
334        Returns:
335            This object for chaining if desired.
336        """
337        self._vessel_id = self._create_float_param(eq, min_val, max_val)
338        return self

Filter on name of the vessel at the time the observation was made.

Filter on name of the vessel at the time the observation was made, overwritting all prior vessel ID filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_date_time( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
340    def filter_date_time(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
341        max_val: OPT_STR = None) -> 'Query':
342        """Filter on the date and time of the haul.
343
344        Filter on the date and time of the haul as an ISO 8601 string. If given
345        an ISO 8601 string, will afscgap.convert from ISO 8601 to the API
346        datetime string format. Similarly, if given a dictionary, all values
347        matching an ISO 8601 string will be afscgap.converted to the API
348        datetime string format. Overwrites all prior date time filters on
349        this Query.
350
351        Args:
352            eq: The exact value that must be matched for a record to be
353                returned. Pass None if no equality filter should be applied.
354                Error thrown if min_val or max_val also provided.
355            min_val: The minimum allowed value, inclusive. Pass None if no
356                minimum value filter should be applied. Defaults to None. Error
357                thrown if eq also proivded.
358            max_val: The maximum allowed value, inclusive. Pass None if no
359                maximum value filter should be applied. Defaults to None. Error
360                thrown if eq also proivded.
361
362        Returns:
363            This object for chaining if desired.
364        """
365        self._date_time = self._create_str_param(eq, min_val, max_val)
366        return self

Filter on the date and time of the haul.

Filter on the date and time of the haul as an ISO 8601 string. If given an ISO 8601 string, will afscgap.convert from ISO 8601 to the API datetime string format. Similarly, if given a dictionary, all values matching an ISO 8601 string will be afscgap.converted to the API datetime string format. Overwrites all prior date time filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_latitude( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'dd') -> Query:
368    def filter_latitude(self, eq: OPT_FLOAT = None,
369        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
370        units: str = 'dd') -> 'Query':
371        """Filter on latitude in decimal degrees associated with the haul.
372
373        Filter on latitude in decimal degrees associated with the haul,
374        overwritting all prior latitude filters on this Query.
375
376        Args:
377            eq: The exact value that must be matched for a record to be
378                returned. Pass None if no equality filter should be applied.
379                Error thrown if min_val or max_val also provided.
380            min_val: The minimum allowed value, inclusive. Pass None if no
381                minimum value filter should be applied. Defaults to None. Error
382                thrown if eq also proivded.
383            max_val: The maximum allowed value, inclusive. Pass None if no
384                maximum value filter should be applied. Defaults to None. Error
385                thrown if eq also proivded.
386            units: The units in which the filter values are provided. Currently
387                only dd supported.
388
389        Returns:
390            This object for chaining if desired.
391        """
392        self._latitude_dd = self._create_float_param(
393            afscgap.convert.convert(eq, units, 'dd'),
394            afscgap.convert.convert(min_val, units, 'dd'),
395            afscgap.convert.convert(max_val, units, 'dd')
396        )
397        return self

Filter on latitude in decimal degrees associated with the haul.

Filter on latitude in decimal degrees associated with the haul, overwritting all prior latitude filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the filter values are provided. Currently only dd supported.
Returns:

This object for chaining if desired.

def filter_longitude( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'dd') -> Query:
399    def filter_longitude(self, eq: OPT_FLOAT = None,
400        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
401        units: str = 'dd') -> 'Query':
402        """Filter on longitude in decimal degrees associated with the haul.
403
404        Filter on longitude in decimal degrees associated with the haul,
405        overwritting all prior longitude filters on this Query.
406
407        Args:
408            eq: The exact value that must be matched for a record to be
409                returned. Pass None if no equality filter should be applied.
410                Error thrown if min_val or max_val also provided.
411            min_val: The minimum allowed value, inclusive. Pass None if no
412                minimum value filter should be applied. Defaults to None. Error
413                thrown if eq also proivded.
414            max_val: The maximum allowed value, inclusive. Pass None if no
415                maximum value filter should be applied. Defaults to None. Error
416                thrown if eq also proivded.
417            units: The units in which the filter values are provided. Currently
418                only dd supported.
419
420        Returns:
421            This object for chaining if desired.
422        """
423        self._longitude_dd = self._create_float_param(
424            afscgap.convert.convert(eq, units, 'dd'),
425            afscgap.convert.convert(min_val, units, 'dd'),
426            afscgap.convert.convert(max_val, units, 'dd')
427        )
428        return self

Filter on longitude in decimal degrees associated with the haul.

Filter on longitude in decimal degrees associated with the haul, overwritting all prior longitude filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the filter values are provided. Currently only dd supported.
Returns:

This object for chaining if desired.

def filter_species_code( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
430    def filter_species_code(self, eq: OPT_FLOAT = None,
431        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None) -> 'Query':
432        """Filter on unique ID associated with the species observed.
433
434        Filter on unique ID associated with the species observed, overwritting
435        all prior species code filters on this Query.
436
437        Args:
438            eq: The exact value that must be matched for a record to be
439                returned. Pass None if no equality filter should be applied.
440                Error thrown if min_val or max_val also provided.
441            min_val: The minimum allowed value, inclusive. Pass None if no
442                minimum value filter should be applied. Defaults to None. Error
443                thrown if eq also proivded.
444            max_val: The maximum allowed value, inclusive. Pass None if no
445                maximum value filter should be applied. Defaults to None. Error
446                thrown if eq also proivded.
447
448        Returns:
449            This object for chaining if desired.
450        """
451        self._species_code = self._create_float_param(eq, min_val, max_val)
452        return self

Filter on unique ID associated with the species observed.

Filter on unique ID associated with the species observed, overwritting all prior species code filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_common_name( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
454    def filter_common_name(self, eq: STR_PARAM = None, min_val: OPT_STR = None,
455        max_val: OPT_STR = None) -> 'Query':
456        """Filter on the "common name" associated with the species observed.
457
458        Filter on the "common name" associated with the species observed,
459        overwritting all prior common name filters on this Query.
460
461        Args:
462            eq: The exact value that must be matched for a record to be
463                returned. Pass None if no equality filter should be applied.
464                Error thrown if min_val or max_val also provided.
465            min_val: The minimum allowed value, inclusive. Pass None if no
466                minimum value filter should be applied. Defaults to None. Error
467                thrown if eq also proivded.
468            max_val: The maximum allowed value, inclusive. Pass None if no
469                maximum value filter should be applied. Defaults to None. Error
470                thrown if eq also proivded.
471
472        Returns:
473            This object for chaining if desired.
474        """
475        self._common_name = self._create_str_param(eq, min_val, max_val)
476        return self

Filter on the "common name" associated with the species observed.

Filter on the "common name" associated with the species observed, overwritting all prior common name filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_scientific_name( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
478    def filter_scientific_name(self, eq: STR_PARAM = None,
479        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
480        """Filter on the "scientific name" associated with the species observed.
481
482        Filter on the "scientific name" associated with the species observed,
483        overwritting all prior scientific name filters on this Query.
484
485        Args:
486            eq: The exact value that must be matched for a record to be
487                returned. Pass None if no equality filter should be applied.
488                Error thrown if min_val or max_val also provided.
489            min_val: The minimum allowed value, inclusive. Pass None if no
490                minimum value filter should be applied. Defaults to None. Error
491                thrown if eq also proivded.
492            max_val: The maximum allowed value, inclusive. Pass None if no
493                maximum value filter should be applied. Defaults to None. Error
494                thrown if eq also proivded.
495
496        Returns:
497            This object for chaining if desired.
498        """
499        self._scientific_name = self._create_str_param(eq, min_val, max_val)
500        return self

Filter on the "scientific name" associated with the species observed.

Filter on the "scientific name" associated with the species observed, overwritting all prior scientific name filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_taxon_confidence( self, eq: Union[str, dict, NoneType] = None, min_val: Optional[str] = None, max_val: Optional[str] = None) -> Query:
502    def filter_taxon_confidence(self, eq: STR_PARAM = None,
503        min_val: OPT_STR = None, max_val: OPT_STR = None) -> 'Query':
504        """Filter on confidence flag regarding ability to identify species.
505
506        Filter on confidence flag regarding ability to identify species,
507        overwritting all taxon confidence filters on this Query.
508
509        Args:
510            eq: The exact value that must be matched for a record to be
511                returned. Pass None if no equality filter should be applied.
512                Error thrown if min_val or max_val also provided.
513            min_val: The minimum allowed value, inclusive. Pass None if no
514                minimum value filter should be applied. Defaults to None. Error
515                thrown if eq also proivded.
516            max_val: The maximum allowed value, inclusive. Pass None if no
517                maximum value filter should be applied. Defaults to None. Error
518                thrown if eq also proivded.
519
520        Returns:
521            This object for chaining if desired.
522        """
523        self._taxon_confidence = self._create_str_param(eq, min_val, max_val)
524        return self

Filter on confidence flag regarding ability to identify species.

Filter on confidence flag regarding ability to identify species, overwritting all taxon confidence filters on this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_cpue_weight( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'kg/ha') -> Query:
526    def filter_cpue_weight(self, eq: OPT_FLOAT = None,
527        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
528        units: str = 'kg/ha') -> 'Query':
529        """Filter on catch per unit effort.
530
531        Filter on catch per unit effort as weight divided by net area if
532        available. Overwrites all prior CPUE weight filters applied to this
533        Query.
534
535        Args:
536            eq: The exact value that must be matched for a record to be
537                returned. Pass None if no equality filter should be applied.
538                Error thrown if min_val or max_val also provided.
539            min_val: The minimum allowed value, inclusive. Pass None if no
540                minimum value filter should be applied. Defaults to None. Error
541                thrown if eq also proivded.
542            max_val: The maximum allowed value, inclusive. Pass None if no
543                maximum value filter should be applied. Defaults to None. Error
544                thrown if eq also proivded.
545            units: The units for the catch per unit effort provided. Options:
546                kg/ha, kg/km2, kg1000/km2. Defaults to kg/ha.
547
548        Returns:
549            This object for chaining if desired.
550        """
551        param = self._create_float_param(eq, min_val, max_val)
552
553        self._cpue_kgha = afscgap.param.EmptyParam()
554        self._cpue_kgkm2 = afscgap.param.EmptyParam()
555        self._cpue_kg1000km2 = afscgap.param.EmptyParam()
556
557        if units == 'kg/ha':
558            self._cpue_kgha = param
559        elif units == 'kg/km2':
560            self._cpue_kgkm2 = param
561        elif units == 'kg1000/km2':
562            self._cpue_kg1000km2 = param
563        else:
564            raise RuntimeError('Unrecognized units ' + units)
565
566        return self

Filter on catch per unit effort.

Filter on catch per unit effort as weight divided by net area if available. Overwrites all prior CPUE weight filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units for the catch per unit effort provided. Options: kg/ha, kg/km2, kg1000/km2. Defaults to kg/ha.
Returns:

This object for chaining if desired.

def filter_cpue_count( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'count/ha') -> Query:
568    def filter_cpue_count(self, eq: OPT_FLOAT = None,
569        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
570        units: str = 'count/ha') -> 'Query':
571        """Filter catch per unit effort as count over area in hectares.
572
573        Filter on catch number divided by net sweep area if available (count /
574        hectares). Overwrites all prior CPUE count filters applied to this
575        Query.
576
577        Args:
578            eq: The exact value that must be matched for a record to be
579                returned. Pass None if no equality filter should be applied.
580                Error thrown if min_val or max_val also provided.
581            min_val: The minimum allowed value, inclusive. Pass None if no
582                minimum value filter should be applied. Defaults to None. Error
583                thrown if eq also proivded.
584            max_val: The maximum allowed value, inclusive. Pass None if no
585                maximum value filter should be applied. Defaults to None. Error
586                thrown if eq also proivded.
587            units: The units for the given catch per unit effort. Options:
588                count/ha, count/km2, and count1000/km2. Defaults to count/ha.
589
590        Returns:
591            This object for chaining if desired.
592        """
593        param = self._create_float_param(eq, min_val, max_val)
594
595        self._cpue_noha = afscgap.param.EmptyParam()
596        self._cpue_nokm2 = afscgap.param.EmptyParam()
597        self._cpue_no1000km2 = afscgap.param.EmptyParam()
598
599        if units == 'count/ha':
600            self._cpue_noha = param
601        elif units == 'count/km2':
602            self._cpue_nokm2 = param
603        elif units == 'count1000/km2':
604            self._cpue_no1000km2 = param
605        else:
606            raise RuntimeError('Unrecognized units ' + units)
607
608        return self

Filter catch per unit effort as count over area in hectares.

Filter on catch number divided by net sweep area if available (count / hectares). Overwrites all prior CPUE count filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units for the given catch per unit effort. Options: count/ha, count/km2, and count1000/km2. Defaults to count/ha.
Returns:

This object for chaining if desired.

def filter_weight( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'kg') -> Query:
610    def filter_weight(self, eq: OPT_FLOAT = None,
611        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
612        units: str = 'kg') -> 'Query':
613        """Filter on taxon weight (kg) if available.
614
615        Filter on taxon weight (kg) if available, overwrites all prior weight
616        filters applied to this Query.
617
618        Args:
619            eq: The exact value that must be matched for a record to be
620                returned. Pass None if no equality filter should be applied.
621                Error thrown if min_val or max_val also provided.
622            min_val: The minimum allowed value, inclusive. Pass None if no
623                minimum value filter should be applied. Defaults to None. Error
624                thrown if eq also proivded.
625            max_val: The maximum allowed value, inclusive. Pass None if no
626                maximum value filter should be applied. Defaults to None. Error
627                thrown if eq also proivded.
628            units: The units in which the weight are given. Options are
629                g, kg for grams and kilograms respectively. Deafults to kg.
630
631        Returns:
632            This object for chaining if desired.
633        """
634        self._weight_kg = self._create_float_param(
635            afscgap.convert.convert(eq, units, 'kg'),
636            afscgap.convert.convert(min_val, units, 'kg'),
637            afscgap.convert.convert(max_val, units, 'kg')
638        )
639        return self

Filter on taxon weight (kg) if available.

Filter on taxon weight (kg) if available, overwrites all prior weight filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the weight are given. Options are g, kg for grams and kilograms respectively. Deafults to kg.
Returns:

This object for chaining if desired.

def filter_count( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None) -> Query:
641    def filter_count(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
642        max_val: OPT_FLOAT = None) -> 'Query':
643        """Filter on total number of organism individuals in haul.
644
645        Filter on total number of organism individuals in haul, overwrites all
646        prior count filters applied to this Query.
647
648        Args:
649            eq: The exact value that must be matched for a record to be
650                returned. Pass None if no equality filter should be applied.
651                Error thrown if min_val or max_val also provided.
652            min_val: The minimum allowed value, inclusive. Pass None if no
653                minimum value filter should be applied. Defaults to None. Error
654                thrown if eq also proivded.
655            max_val: The maximum allowed value, inclusive. Pass None if no
656                maximum value filter should be applied. Defaults to None. Error
657                thrown if eq also proivded.
658
659        Returns:
660            This object for chaining if desired.
661        """
662        self._count = self._create_float_param(eq, min_val, max_val)
663        return self

Filter on total number of organism individuals in haul.

Filter on total number of organism individuals in haul, overwrites all prior count filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
Returns:

This object for chaining if desired.

def filter_bottom_temperature( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'c') -> Query:
665    def filter_bottom_temperature(self, eq: OPT_FLOAT = None,
666        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
667        units: str = 'c') -> 'Query':
668        """Filter on bottom temperature.
669
670        Filter on bottom temperature associated with observation if available in
671        the units given. Overwrites all prior bottom temperature filters applied
672        to this Query.
673
674        Args:
675            eq: The exact value that must be matched for a record to be
676                returned. Pass None if no equality filter should be applied.
677                Error thrown if min_val or max_val also provided.
678            min_val: The minimum allowed value, inclusive. Pass None if no
679                minimum value filter should be applied. Defaults to None. Error
680                thrown if eq also proivded.
681            max_val: The maximum allowed value, inclusive. Pass None if no
682                maximum value filter should be applied. Defaults to None. Error
683                thrown if eq also proivded.
684            units: The units in which the temperature filter values are given.
685                Options: c or f for Celcius and Fahrenheit respectively.
686                Defaults to c.
687
688        Returns:
689            This object for chaining if desired.
690        """
691        self._bottom_temperature_c = self._create_float_param(
692            afscgap.convert.convert(eq, units, 'c'),
693            afscgap.convert.convert(min_val, units, 'c'),
694            afscgap.convert.convert(max_val, units, 'c')
695        )
696        return self

Filter on bottom temperature.

Filter on bottom temperature associated with observation if available in the units given. Overwrites all prior bottom temperature filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the temperature filter values are given. Options: c or f for Celcius and Fahrenheit respectively. Defaults to c.
Returns:

This object for chaining if desired.

def filter_surface_temperature( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'c') -> Query:
698    def filter_surface_temperature(self, eq: OPT_FLOAT = None,
699        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
700        units: str = 'c') -> 'Query':
701        """Filter on surface temperature.
702
703        Filter on surface temperature associated with observation if available
704        in the units given. Overwrites all prior bottom temperature filters
705        applied to this Query.
706
707        Args:
708            eq: The exact value that must be matched for a record to be
709                returned. Pass None if no equality filter should be applied.
710                Error thrown if min_val or max_val also provided.
711            min_val: The minimum allowed value, inclusive. Pass None if no
712                minimum value filter should be applied. Defaults to None. Error
713                thrown if eq also proivded.
714            max_val: The maximum allowed value, inclusive. Pass None if no
715                maximum value filter should be applied. Defaults to None. Error
716                thrown if eq also proivded.
717            units: The units in which the temperature filter values are given.
718                Options: c or f for Celcius and Fahrenheit respectively.
719                Defaults to c.
720
721        Returns:
722            This object for chaining if desired.
723        """
724        self._surface_temperature_c = self._create_float_param(
725            afscgap.convert.convert(eq, units, 'c'),
726            afscgap.convert.convert(min_val, units, 'c'),
727            afscgap.convert.convert(max_val, units, 'c')
728        )
729        return self

Filter on surface temperature.

Filter on surface temperature associated with observation if available in the units given. Overwrites all prior bottom temperature filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the temperature filter values are given. Options: c or f for Celcius and Fahrenheit respectively. Defaults to c.
Returns:

This object for chaining if desired.

def filter_depth( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'm') -> Query:
731    def filter_depth(self, eq: OPT_FLOAT = None, min_val: OPT_FLOAT = None,
732        max_val: OPT_FLOAT = None, units: str = 'm') -> 'Query':
733        """Filter on depth of the bottom in meters.
734
735        Filter on depth of the bottom in meters, overwrites all prior depth
736        filters applied to this Query.
737
738        Args:
739            eq: The exact value that must be matched for a record to be
740                returned. Pass None if no equality filter should be applied.
741                Error thrown if min_val or max_val also provided.
742            min_val: The minimum allowed value, inclusive. Pass None if no
743                minimum value filter should be applied. Defaults to None. Error
744                thrown if eq also proivded.
745            max_val: The maximum allowed value, inclusive. Pass None if no
746                maximum value filter should be applied. Defaults to None. Error
747                thrown if eq also proivded.
748            units: The units in which the distance are given. Options:
749                m or km for meters and kilometers respectively. Defaults to m.
750
751        Returns:
752            This object for chaining if desired.
753        """
754        self._depth_m = self._create_float_param(
755            afscgap.convert.convert(eq, units, 'm'),
756            afscgap.convert.convert(min_val, units, 'm'),
757            afscgap.convert.convert(max_val, units, 'm')
758        )
759        return self

Filter on depth of the bottom in meters.

Filter on depth of the bottom in meters, overwrites all prior depth filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the distance are given. Options: m or km for meters and kilometers respectively. Defaults to m.
Returns:

This object for chaining if desired.

def filter_distance_fished( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'm') -> Query:
761    def filter_distance_fished(self, eq: OPT_FLOAT = None,
762        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
763        units: str = 'm') -> 'Query':
764        """Filter on distance of the net fished.
765
766        Filter on distance of the net fished, overwritting prior distance fished
767        filters applied to this Query.
768
769        Args:
770            eq: The exact value that must be matched for a record to be
771                returned. Pass None if no equality filter should be applied.
772                Error thrown if min_val or max_val also provided.
773            min_val: The minimum allowed value, inclusive. Pass None if no
774                minimum value filter should be applied. Defaults to None. Error
775                thrown if eq also proivded.
776            max_val: The maximum allowed value, inclusive. Pass None if no
777                maximum value filter should be applied. Defaults to None. Error
778                thrown if eq also proivded.
779            units: The units in which the distance values are given. Options:
780                m or km for meters and kilometers respectively. Defaults to m.
781
782        Returns:
783            This object for chaining if desired.
784        """
785        def convert_to_km(target, units):
786            return afscgap.convert.convert(target, units, 'km')
787
788        self._distance_fished_km = self._create_float_param(
789            convert_to_km(eq, units),
790            convert_to_km(min_val, units),
791            convert_to_km(max_val, units)
792        )
793        return self

Filter on distance of the net fished.

Filter on distance of the net fished, overwritting prior distance fished filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the distance values are given. Options: m or km for meters and kilometers respectively. Defaults to m.
Returns:

This object for chaining if desired.

def filter_net_width( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'm') -> Query:
795    def filter_net_width(self, eq: OPT_FLOAT = None,
796        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
797        units: str = 'm') -> 'Query':
798        """Filter on distance of the net fished.
799
800        Filter on distance of the net fished, overwritting prior net width
801        filters applied to this Query.
802
803        Args:
804            eq: The exact value that must be matched for a record to be
805                returned. Pass None if no equality filter should be applied.
806                Error thrown if min_val or max_val also provided.
807            min_val: The minimum allowed value, inclusive. Pass None if no
808                minimum value filter should be applied. Defaults to None. Error
809                thrown if eq also proivded.
810            max_val: The maximum allowed value, inclusive. Pass None if no
811                maximum value filter should be applied. Defaults to None. Error
812                thrown if eq also proivded.
813            units: The units in which the distance should be returned. Options:
814                m or km for meters and kilometers respectively. Defaults to m.
815
816        Returns:
817            This object for chaining if desired.
818        """
819        self._net_width_m = self._create_float_param(
820            afscgap.convert.convert(eq, units, 'm'),
821            afscgap.convert.convert(min_val, units, 'm'),
822            afscgap.convert.convert(max_val, units, 'm')
823        )
824        return self

Filter on distance of the net fished.

Filter on distance of the net fished, overwritting prior net width filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the distance should be returned. Options: m or km for meters and kilometers respectively. Defaults to m.
Returns:

This object for chaining if desired.

def filter_net_height( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'm') -> Query:
826    def filter_net_height(self, eq: OPT_FLOAT = None,
827        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
828        units: str = 'm') -> 'Query':
829        """Filter on height of the net fished.
830
831        Filter on height of the net fished, overwritting prior net height
832        filters applied to this Query.
833
834        Args:
835            eq: The exact value that must be matched for a record to be
836                returned. Pass None if no equality filter should be applied.
837                Error thrown if min_val or max_val also provided.
838            min_val: The minimum allowed value, inclusive. Pass None if no
839                minimum value filter should be applied. Defaults to None. Error
840                thrown if eq also proivded.
841            max_val: The maximum allowed value, inclusive. Pass None if no
842                maximum value filter should be applied. Defaults to None. Error
843                thrown if eq also proivded.
844            units: The units in which the distance should be returned. Options:
845                m or km for meters and kilometers respectively. Defaults to m.
846
847        Returns:
848            This object for chaining if desired.
849        """
850        self._net_height_m = self._create_float_param(
851            afscgap.convert.convert(eq, units, 'm'),
852            afscgap.convert.convert(min_val, units, 'm'),
853            afscgap.convert.convert(max_val, units, 'm')
854        )
855        return self

Filter on height of the net fished.

Filter on height of the net fished, overwritting prior net height filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the distance should be returned. Options: m or km for meters and kilometers respectively. Defaults to m.
Returns:

This object for chaining if desired.

def filter_area_swept( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'm') -> Query:
857    def filter_area_swept(self, eq: OPT_FLOAT = None,
858        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
859        units: str = 'm') -> 'Query':
860        """Filter on area covered by the net while fishing.
861
862        Filter on area covered by the net while fishing, overwritting prior
863        area swept filters applied to this Query.
864
865        Args:
866            eq: The exact value that must be matched for a record to be
867                returned. Pass None if no equality filter should be applied.
868                Error thrown if min_val or max_val also provided.
869            min_val: The minimum allowed value, inclusive. Pass None if no
870                minimum value filter should be applied. Defaults to None. Error
871                thrown if eq also proivded.
872            max_val: The maximum allowed value, inclusive. Pass None if no
873                maximum value filter should be applied. Defaults to None. Error
874                thrown if eq also proivded.
875            units: The units in which the area should be returned. Options:
876                ha, m2, km2. Defaults to ha.
877
878        Returns:
879            This object for chaining if desired.
880        """
881        self._area_swept_ha = self._create_float_param(
882            afscgap.convert.convert(eq, units, 'ha'),
883            afscgap.convert.convert(min_val, units, 'ha'),
884            afscgap.convert.convert(max_val, units, 'ha')
885        )
886        return self

Filter on area covered by the net while fishing.

Filter on area covered by the net while fishing, overwritting prior area swept filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the area should be returned. Options: ha, m2, km2. Defaults to ha.
Returns:

This object for chaining if desired.

def filter_duration( self, eq: Optional[float] = None, min_val: Optional[float] = None, max_val: Optional[float] = None, units: str = 'hr') -> Query:
888    def filter_duration(self, eq: OPT_FLOAT = None,
889        min_val: OPT_FLOAT = None, max_val: OPT_FLOAT = None,
890        units: str = 'hr') -> 'Query':
891        """Filter on duration of the haul.
892
893        Filter on duration of the haul, ovewritting all prior duration filters
894        applied to this Query.
895
896        Args:
897            eq: The exact value that must be matched for a record to be
898                returned. Pass None if no equality filter should be applied.
899                Error thrown if min_val or max_val also provided.
900            min_val: The minimum allowed value, inclusive. Pass None if no
901                minimum value filter should be applied. Defaults to None. Error
902                thrown if eq also proivded.
903            max_val: The maximum allowed value, inclusive. Pass None if no
904                maximum value filter should be applied. Defaults to None. Error
905                thrown if eq also proivded.
906            units: The units in which the duration should be returned. Options:
907                day, hr, min. Defaults to hr.
908
909        Returns:
910            This object for chaining if desired.
911        """
912        self._duration_hr = self._create_float_param(
913            afscgap.convert.convert(eq, units, 'hr'),
914            afscgap.convert.convert(min_val, units, 'hr'),
915            afscgap.convert.convert(max_val, units, 'hr')
916        )
917        return self

Filter on duration of the haul.

Filter on duration of the haul, ovewritting all prior duration filters applied to this Query.

Arguments:
  • eq: The exact value that must be matched for a record to be returned. Pass None if no equality filter should be applied. Error thrown if min_val or max_val also provided.
  • min_val: The minimum allowed value, inclusive. Pass None if no minimum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • max_val: The maximum allowed value, inclusive. Pass None if no maximum value filter should be applied. Defaults to None. Error thrown if eq also proivded.
  • units: The units in which the duration should be returned. Options: day, hr, min. Defaults to hr.
Returns:

This object for chaining if desired.

def set_limit(self, limit: Optional[int]) -> Query:
919    def set_limit(self, limit: OPT_INT) -> 'Query':
920        """Set the max number of results.
921
922        Set the max number of results, overwritting prior limit settings on this
923        Query.
924
925        Args:
926            limit: The maximum number of results to retrieve per HTTP request.
927                If None or not provided, will use API's default.
928
929        Returns:
930            This object for chaining if desired.
931        """
932        self._limit = limit
933        return self

Set the max number of results.

Set the max number of results, overwritting prior limit settings on this Query.

Arguments:
  • limit: The maximum number of results to retrieve per HTTP request. If None or not provided, will use API's default.
Returns:

This object for chaining if desired.

def set_filter_incomplete(self, filter_incomplete: bool) -> Query:
935    def set_filter_incomplete(self, filter_incomplete: bool) -> 'Query':
936        """Indicate if incomplete records should be filtered out.
937
938        Indicate if incomplete records should be filtered out, overwritting
939        prior incomplete filter settings on this Query.
940
941        Args:
942            filter_incomplete: Flag indicating if "incomplete" records should be
943                filtered. If true, "incomplete" records are silently filtered
944                from the results, putting them in the invalid records queue. If
945                false, they are included and their is_complete() will return
946                false. Defaults to false.
947
948        Returns:
949            This object for chaining if desired.
950        """
951        self._filter_incomplete = filter_incomplete
952        return self

Indicate if incomplete records should be filtered out.

Indicate if incomplete records should be filtered out, overwritting prior incomplete filter settings on this Query.

Arguments:
  • filter_incomplete: Flag indicating if "incomplete" records should be filtered. If true, "incomplete" records are silently filtered from the results, putting them in the invalid records queue. If false, they are included and their is_complete() will return false. Defaults to false.
Returns:

This object for chaining if desired.

def set_presence_only(self, presence_only: bool) -> Query:
954    def set_presence_only(self, presence_only: bool) -> 'Query':
955        """Indicate if zero catch inference should be enabled.
956
957        Indicate if zero catch inference should be enabled, overwritting prior
958        abscence / zero catch data settings on this Query.
959
960        Args:
961            presence_only: Flag indicating if abscence / zero catch data should
962                be inferred. If false, will run abscence data inference. If
963                true, will return presence only data as returned by the NOAA API
964                service. Defaults to true.
965
966        Returns:
967            This object for chaining if desired.
968        """
969        self._presence_only = presence_only
970        return self

Indicate if zero catch inference should be enabled.

Indicate if zero catch inference should be enabled, overwritting prior abscence / zero catch data settings on this Query.

Arguments:
  • presence_only: Flag indicating if abscence / zero catch data should be inferred. If false, will run abscence data inference. If true, will return presence only data as returned by the NOAA API service. Defaults to true.
Returns:

This object for chaining if desired.

def set_suppress_large_warning(self, supress: bool) -> Query:
972    def set_suppress_large_warning(self, supress: bool) -> 'Query':
973        """Indicate if the large results warning should be supressed.
974
975        Indicate if the large results warning should be supressed, overwritting
976        prior large results warning supressions settings on this Query.
977
978        Args:
979            suppress_large_warning: Indicate if the library should warn when an
980                operation may consume a large amount of memory. If true, the
981                warning will not be emitted. Defaults to true.
982
983        Returns:
984            This object for chaining if desired.
985        """
986        self._suppress_large_warning = supress
987        return self

Indicate if the large results warning should be supressed.

Indicate if the large results warning should be supressed, overwritting prior large results warning supressions settings on this Query.

Arguments:
  • suppress_large_warning: Indicate if the library should warn when an operation may consume a large amount of memory. If true, the warning will not be emitted. Defaults to true.
Returns:

This object for chaining if desired.

def set_warn_function( self, warn_function: Optional[Callable[[str], NoneType]]) -> Query:
 989    def set_warn_function(self, warn_function: WARN_FUNCTION) -> 'Query':
 990        """Indicate how warnings should be emitted.
 991
 992        Indicate how warnings should be emitted, overwritting the prior warning
 993        function settings on this Query.
 994
 995        Args:
 996            warn_function: Function to call with a message describing warnings
 997                encountered. If None, will use warnings.warn. Defaults to None.
 998
 999        Returns:
1000            This object for chaining if desired.
1001        """
1002        self._warn_function = warn_function
1003        return self

Indicate how warnings should be emitted.

Indicate how warnings should be emitted, overwritting the prior warning function settings on this Query.

Arguments:
  • warn_function: Function to call with a message describing warnings encountered. If None, will use warnings.warn. Defaults to None.
Returns:

This object for chaining if desired.

def execute(self) -> afscgap.cursor.Cursor:
1005    def execute(self) -> afscgap.cursor.Cursor:
1006        """Execute the query built up in this object.
1007
1008        Execute the query built up in this object using its current state. Note
1009        that later changes to this builder will not impact prior returned
1010        Cursors from execute.
1011
1012        Returns:
1013            Cursor to manage HTTP requests and query results.
1014        """
1015        params_dict = {
1016            'year': self._year,
1017            'srvy': self._srvy,
1018            'survey': self._survey,
1019            'survey_id': self._survey_id,
1020            'cruise': self._cruise,
1021            'haul': self._haul,
1022            'stratum': self._stratum,
1023            'station': self._station,
1024            'vessel_name': self._vessel_name,
1025            'vessel_id': self._vessel_id,
1026            'date_time': self._date_time,
1027            'latitude_dd': self._latitude_dd,
1028            'longitude_dd': self._longitude_dd,
1029            'species_code': self._species_code,
1030            'common_name': self._common_name,
1031            'scientific_name': self._scientific_name,
1032            'taxon_confidence': self._taxon_confidence,
1033            'cpue_kgha': self._cpue_kgha,
1034            'cpue_kgkm2': self._cpue_kgkm2,
1035            'cpue_kg1000km2': self._cpue_kg1000km2,
1036            'cpue_noha': self._cpue_noha,
1037            'cpue_nokm2': self._cpue_nokm2,
1038            'cpue_no1000km2': self._cpue_no1000km2,
1039            'weight_kg': self._weight_kg,
1040            'count': self._count,
1041            'bottom_temperature_c': self._bottom_temperature_c,
1042            'surface_temperature_c': self._surface_temperature_c,
1043            'depth_m': self._depth_m,
1044            'distance_fished_km': self._distance_fished_km,
1045            'net_width_m': self._net_width_m,
1046            'net_height_m': self._net_height_m,
1047            'area_swept_ha': self._area_swept_ha,
1048            'duration_hr': self._duration_hr
1049        }
1050
1051        meta_params = afscgap.flat_model.ExecuteMetaParams(
1052            self._base_url if self._base_url else DEFAULT_URL,
1053            self._requestor,
1054            self._limit,
1055            self._filter_incomplete,
1056            self._presence_only,
1057            self._suppress_large_warning,
1058            self._warn_function
1059        )
1060
1061        return afscgap.flat.execute(params_dict, meta_params)

Execute the query built up in this object.

Execute the query built up in this object using its current state. Note that later changes to this builder will not impact prior returned Cursors from execute.

Returns:

Cursor to manage HTTP requests and query results.