Skip to content

Commit

Permalink
Isort packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed May 10, 2023
1 parent d1a6ee2 commit 109c6b4
Show file tree
Hide file tree
Showing 121 changed files with 340 additions and 277 deletions.
4 changes: 2 additions & 2 deletions disdrodb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from importlib.metadata import version, PackageNotFoundError
from importlib.metadata import PackageNotFoundError, version

from disdrodb.api.io import (
available_stations,
available_campaigns,
available_data_sources,
available_stations,
)
from disdrodb.api.metadata import read_station_metadata
from disdrodb.l0.standards import available_sensor_name
Expand Down
3 changes: 2 additions & 1 deletion disdrodb/api/info.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re
import os
import re

import numpy as np
from trollsift import Parser

Expand Down
7 changes: 4 additions & 3 deletions disdrodb/api/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.

import os
import glob
import yaml
import os

import numpy as np
import yaml


def _get_disdrodb_directory(
Expand All @@ -31,8 +32,8 @@ def _get_disdrodb_directory(
campaign_name="",
check_exist=True,
):
from disdrodb.l0.io import _check_directory_exist
from disdrodb.api.checks import check_disdrodb_dir
from disdrodb.l0.io import _check_directory_exist

# Check if disdrodb_dir has a valid name
check_disdrodb_dir(disdrodb_dir)
Expand Down
4 changes: 3 additions & 1 deletion disdrodb/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.
import glob
import os

import yaml
import glob

from disdrodb.api.io import _get_disdrodb_directory


Expand Down
6 changes: 3 additions & 3 deletions disdrodb/data_transfer/download_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from typing import List, Optional, Union

import click
import pooch
import tqdm
import click

from typing import Union, Optional, List

from disdrodb.api.metadata import _read_yaml_file, get_list_metadata
from disdrodb.utils.compression import _unzip_file
Expand Down
8 changes: 4 additions & 4 deletions disdrodb/data_transfer/upload_data.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import click
from typing import List, Optional

from typing import Optional, List
import click

from disdrodb.api.metadata import _read_yaml_file, get_list_metadata, _write_yaml_file
from disdrodb.utils.zenodo import _create_zenodo_deposition, _upload_file_to_zenodo
from disdrodb.api.metadata import _read_yaml_file, _write_yaml_file, get_list_metadata
from disdrodb.utils.compression import _zip_dir
from disdrodb.utils.zenodo import _create_zenodo_deposition, _upload_file_to_zenodo


def click_upload_option(function: object):
Expand Down
12 changes: 6 additions & 6 deletions disdrodb/l0/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from disdrodb.l0.check_metadata import (
check_archive_metadata_compliance,
check_archive_metadata_geolocation,
)
from disdrodb.l0.l0_processing import (
run_l0a,
run_l0b_from_nc,
run_disdrodb_l0,
run_disdrodb_l0_station,
run_l0a,
run_l0b_from_nc,
)
from disdrodb.l0.l0_reader import available_readers
from disdrodb.l0.check_metadata import (
check_archive_metadata_geolocation,
check_archive_metadata_compliance,
)

__all__ = [
"run_l0a",
Expand Down
11 changes: 4 additions & 7 deletions disdrodb/l0/check_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# -*- coding: utf-8 -*-
import glob
import os
from typing import List, Optional, Union

from typing import List, Union, Optional
import numpy as np
from pydantic import BaseModel, ValidationError, validator

from disdrodb.l0.standards import available_sensor_name


import numpy as np
from disdrodb.l0.standards import (
available_sensor_name,
get_configs_dir,
get_diameter_bin_center,
get_diameter_bin_lower,
get_diameter_bin_upper,
Expand All @@ -19,11 +18,9 @@
get_velocity_bin_lower,
get_velocity_bin_upper,
get_velocity_bin_width,
get_configs_dir,
read_config_yml,
)


CONFIG_FILES_LIST = [
"bins_diameter.yml",
"bins_velocity.yml",
Expand Down
18 changes: 9 additions & 9 deletions disdrodb/l0/check_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
# -*- coding: utf-8 -*-

import os
import yaml
from typing import Union

import yaml

from disdrodb.api.metadata import get_list_metadata, read_station_metadata
from disdrodb.l0.io import (
get_disdrodb_dir,
get_data_source,
get_campaign_name,
get_data_source,
get_disdrodb_dir,
)
from disdrodb.api.metadata import read_station_metadata
from disdrodb.l0.l0_reader import _check_metadata_reader
from disdrodb.l0.metadata import (
_check_metadata_keys,
_check_metadata_data_source,
_check_metadata_campaign_name,
_check_metadata_station_name,
_check_metadata_data_source,
_check_metadata_keys,
_check_metadata_sensor_name,
_check_metadata_station_name,
check_metadata_compliance,
)

from disdrodb.api.metadata import get_list_metadata

#### --------------------------------------------------------------------------.


Expand Down
7 changes: 3 additions & 4 deletions disdrodb/l0/check_readers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import glob
import os
import shutil
import pandas as pd

import pandas as pd

from disdrodb.l0.l0_reader import get_station_reader
from disdrodb.api.io import _get_disdrodb_directory

from disdrodb.l0.l0_reader import get_station_reader

# current file path
PACKAGE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down
6 changes: 4 additions & 2 deletions disdrodb/l0/check_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.
import logging

import numpy as np
import pandas as pd

from disdrodb.l0.standards import (
get_data_range_dict,
get_l0a_dtype,
get_valid_values_dict,
get_data_range_dict,
)

# Logger
from disdrodb.utils.logger import (
log_info,
log_error,
log_info,
)

logger = logging.getLogger(__name__)
Expand Down
16 changes: 8 additions & 8 deletions disdrodb/l0/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.
import glob
import logging
import os
import shutil
import glob
from pathlib import Path
from typing import Union

import numpy as np
import pandas as pd
import xarray as xr
from typing import Union

from disdrodb.utils.logger import log_info, log_warning
from pathlib import Path

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -640,8 +642,7 @@ def _check_raw_dir_data_subfolders(raw_dir):

def _check_raw_dir_metadata(raw_dir, verbose=True):
"""Check metadata in the raw_dir directory."""
from disdrodb.l0.metadata import write_default_metadata
from disdrodb.l0.metadata import check_metadata_compliance
from disdrodb.l0.metadata import check_metadata_compliance, write_default_metadata

# Get list of stations
raw_data_dir = os.path.join(raw_dir, "data")
Expand Down Expand Up @@ -707,8 +708,7 @@ def _check_raw_dir_metadata(raw_dir, verbose=True):

def _check_raw_dir_issue(raw_dir, verbose=True):
"""Check issue yaml files in the raw_dir directory."""
from disdrodb.l0.issue import write_default_issue
from disdrodb.l0.issue import check_issue_file
from disdrodb.l0.issue import check_issue_file, write_default_issue

# Get list of stations
raw_data_dir = os.path.join(raw_dir, "data")
Expand Down Expand Up @@ -1005,7 +1005,7 @@ def create_initial_directory_structure(raw_dir, processed_dir, station_name, for

def create_directory_structure(processed_dir, product_level, station_name, force, verbose=False):
"""Create directory structure for L0B and higher DISDRODB products."""
from disdrodb.api.io import check_product_level, _get_list_stations_with_data
from disdrodb.api.io import _get_list_stations_with_data, check_product_level

# Check inputs
check_product_level(product_level)
Expand Down
7 changes: 4 additions & 3 deletions disdrodb/l0/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.

import os
import yaml
import logging
import os

import numpy as np
import pandas as pd
from disdrodb.utils.logger import log_error
import yaml

from disdrodb.utils.logger import log_error

logger = logging.getLogger(__name__)

Expand Down
40 changes: 21 additions & 19 deletions disdrodb/l0/l0_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,45 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.
import datetime
import functools
import logging
import os
import time
import dask
import shutil
import time

import click
import logging
import functools
import datetime
import dask
import dask.bag as db

# Standards
from disdrodb.l0.check_standards import check_sensor_name

# Directory
from disdrodb.l0.io import get_raw_file_list, get_l0a_file_list
from disdrodb.l0.io import (
create_initial_directory_structure,
create_directory_structure,
create_initial_directory_structure,
get_l0a_file_list,
get_raw_file_list,
)
from disdrodb.l0.issue import read_issue

# Metadata & Issue
from disdrodb.l0.metadata import read_metadata
from disdrodb.l0.issue import read_issue

# Standards
from disdrodb.l0.check_standards import check_sensor_name

# L0B_processing
from disdrodb.utils.scripts import _execute_cmd

# Logger
from disdrodb.utils.logger import (
create_file_logger,
close_logger,
create_file_logger,
define_summary_log,
log_info,
# log_warning,
log_error,
log_info,
)

# L0B_processing
from disdrodb.utils.scripts import _execute_cmd

logger = logging.getLogger(__name__)

# -----------------------------------------------------------------------------.
Expand Down Expand Up @@ -177,12 +179,12 @@ def _generate_l0b(
debugging_mode,
parallel,
):
from disdrodb.utils.logger import create_file_logger
from disdrodb.l0.io import get_L0B_fpath, read_L0A_dataframe
from disdrodb.l0.l0b_processing import (
create_l0b_from_l0a,
write_l0b,
)
from disdrodb.utils.logger import create_file_logger

# -----------------------------------------------------------------.
# Create file logger
Expand Down Expand Up @@ -257,9 +259,9 @@ def _generate_l0b_from_nc(
verbose,
parallel,
):
from disdrodb.utils.logger import create_file_logger
from disdrodb.l0.io import get_L0B_fpath
from disdrodb.l0.l0b_processing import process_raw_nc, write_l0b
from disdrodb.utils.logger import create_file_logger

# -----------------------------------------------------------------.
# Create file logger
Expand Down Expand Up @@ -897,8 +899,8 @@ def run_disdrodb_l0_station(
For L0B, it processes just the first 100 rows of 3 L0A files for each station.
The default is False.
"""
from disdrodb.l0.l0b_concat import run_disdrodb_l0b_concat_station
from disdrodb.api.io import _get_disdrodb_directory
from disdrodb.l0.l0b_concat import run_disdrodb_l0b_concat_station

# ---------------------------------------------------------------------.
t_i = time.time()
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/l0/l0_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------.

import os
import logging
import os

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 109c6b4

Please sign in to comment.