Exemplo n.º 1
0
# from lib.db import Postgres, intersect_aoi_where
from lib.logging_utils import create_logger
import lib.constants as constants

# TODO: See if this can be done on scenes table, to facilitate ordering only
#  scenes that meet multilook specifications. As written all overlappng scenes
#  would have to exist in the scenes_onhand table already to be considered for
#  selection. The challenge is not keying off of the filename field when
#  determining pairs. Another possibility is to make this an arguement:
#  select only all-onhand pairs or select from scenes table and determine
#  what is onhand and what needs to be ordered.

# TODO: When locating onhand scenes, ensure there is only one, as fn_pairname
#  is based on id

logger = create_logger(__name__, 'sh', 'INFO')

# External modules
sys.path.append(str(Path(__file__).parent / '..'))
try:
    from db_utils.db import Postgres, intersect_aoi_where
except ImportError as e:
    logger.error('db_utils module not found. It should be adjacent to '
                 'the planet_tools directory. Path: \n{}'.format(sys.path))
    sys.exit()

# Constants
# MULTILOOK_CANDIDATES = 'multilook_candidates'
# SCENES = 'scenes'
# SCENES_ONHAND = 'scenes_onhand'
# ID = 'id'
Exemplo n.º 2
0
import argparse
import datetime
from pathlib import Path
import platform
import os
import sys
import time

from lib.lib import read_ids, get_config, linux2win
from lib.logging_utils import create_logger, create_logfile_path
from lib.order import submit_order, poll_for_success
# from submit_order import submit_order
from lib.order import download_parallel
import lib.constants as constants

logger = create_logger(__name__, 'sh', 'INFO')

default_dst_parent = get_config(constants.DOWNLOAD_LOC)
if platform.system() == constants.WINDOWS:
    default_dst_parent = linux2win(default_dst_parent)

# DELIVERY
DELIVERY_OPTIONS = [constants.AWS, constants.ZIP]


def order_and_download(order_name,
                       order_ids_path,
                       order_selection_path,
                       out_orders_list,
                       order_product_bundle,
                       remove_onhand=True,
Exemplo n.º 3
0
import argparse
import numpy as np
import os
from pathlib import Path
import sys

import pandas as pd
from tqdm import tqdm

# from lib.db import Postgres, generate_sql
from lib.lib import get_config
from lib.logging_utils import create_logger, create_logfile_path
import lib.constants as constants

logger = create_logger(__name__, 'sh', 'INFO')

# External modules
sys.path.append(str(Path(__file__).parent / '..'))
try:
    from db_utils.db import Postgres, generate_sql
except ImportError as e:
    logger.error('db_utils module not found. It should be adjacent to '
                 'the planet_tools directory. Path: \n{}'.format(sys.path))
    sys.exit()


def ingest_off_nadir(export_dir,
                     onhand_scenes_only=True,
                     new_only=True,
                     ext='.csv',
                     dryrun=False):
Exemplo n.º 4
0
import shutil
import sys

import geopandas as gpd
from tqdm import tqdm

# from lib.db import Postgres, ids2sql
from lib.lib import get_config, linux2win, read_ids, write_gdf, \
    get_platform_location, PlanetScene
# from shelve_scenes import shelve_scenes
from lib.logging_utils import create_logger
import lib.constants as constants

# TODO: Add ability to select by either ID (current method) or filename

logger = create_logger(__name__, 'sh', 'DEBUG')

# External modules
sys.path.append(str(Path(__file__).parent / '..'))
try:
    from db_utils.db import Postgres, ids2sql
except ImportError as e:
    logger.error('db_utils module not found. It should be adjacent to '
                 'the planet_tools directory. Path: \n{}'.format(sys.path))
    sys.exit()

# Params
PLATFORM_LOCATION = 'platform_location'
REQUIRED_FIELDS = [constants.ID, constants.SHELVED_LOC]
# Transfer methods
TM_LINK = 'link'
Exemplo n.º 5
0
                        help='Run commands without executing.')

    args = parser.parse_args()

    seraches_list = args.searches_list
    searches_json = args.searches_json
    delete_search_id = args.delete_search_id
    delete_search_name = args.delete_search_name
    verbose = args.verbose
    dryrun = args.dryrun

    if verbose:
        log_lvl = 'DEBUG'
    else:
        log_lvl = 'INFO'
    logger = create_logger(__name__, 'sh', log_lvl)

    s = requests.Session()
    s.auth = (os.getenv(constants.PL_API_KEY), '')

    if seraches_list:
        list_searches(session=s, verbose=verbose)
    if searches_json:
        write_searches(session=s, out_json=searches_json)
    if delete_search_name:
        logger.info('Deleting search by name: {}'.format(delete_search_name))
        delete_saved_search(session=s, search_name=args.delete_search_name, dryrun=dryrun)
    if delete_search_id:
        logger.info('Deleting search by ID: {}'.format(delete_search_id))
        delete_saved_search(session=s, search_id=args.delete_search_id, dryrun=dryrun)
Exemplo n.º 6
0
import argparse
import os
from pathlib import Path
import sys

import geopandas as gpd
from sqlalchemy.exc import ProgrammingError

# from lib.db import Postgres, intersect_aoi_where
from lib.lib import read_ids, write_gdf, parse_group_args
# TODO: Fix this - place attrib_arg_lut dict somewhere better
from lib.search import attrib_arg_lut
from lib.logging_utils import create_logger
import lib.constants as constants

logger = create_logger('lib', 'sh', 'INFO')

# External modules
sys.path.append(str(Path(__file__).parent / '..'))
try:
    from db_utils.db import Postgres, intersect_aoi_where
except ImportError as e:
    logger.error('db_utils module not found. It should be adjacent to '
                 'the planet_tools directory. Path: \n{}'.format(sys.path))
    sys.exit()


def build_argument_sql(att_args=None, months=None,
                       month_min_days=None, month_max_days=None,
                       aoi_path=None, ids=None, ids_field='id',
                       table=constants.SCENES):