Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH/BUG: use unzip from pysatNASA for TIEGCM #132

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pysat_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

name: Test with pysat ecosystem RCs

on: [workflow_dispatch]
on: [push]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

[0.2.0] - 2022-XX-XX
[0.2.0] - 2023-XX-XX
--------------------
* Added support for access to TIEGCM models from the ICON mission
* Maintenance
Expand Down
28 changes: 5 additions & 23 deletions pysatModels/models/ucar_tiegcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import functools
import os
import pandas as pds
import tempfile
import warnings
import zipfile

import pysat

Expand Down Expand Up @@ -214,10 +212,11 @@ def load(fnames, tag='', inst_id='', **kwargs):
'': {'icon': {'remote_dir': '/pub/data/icon/l4/tiegcm/{year:04d}/',
'fname': ''.join(['icon_l4-3_tiegcm_{year:04d}-{month:02d}-',
'{day:02d}_v{version:02d}r{revision:03d}',
'.zip'])}}}
'.zip']),
'zip_method': 'zip'}}}


def download(date_array, tag, inst_id, data_path=None, **kwargs):
def download(date_array, tag, inst_id, data_path, **kwargs):
"""Download UCAR TIE-GCM from NASA CDAWeb.

Parameters
Expand All @@ -232,7 +231,7 @@ def download(date_array, tag, inst_id, data_path=None, **kwargs):
Instrument ID string identifier used for particular dataset. This input
is provided by pysat.
data_path : str or NoneType
Path to directory to download data to. (default=None)
Path to directory to download data to.
**kwargs : dict
Additional keywords supplied by user when invoking the download
routine attached to a pysat.Instrument object are passed to this
Expand All @@ -248,27 +247,10 @@ def download(date_array, tag, inst_id, data_path=None, **kwargs):
if tag == '':
warnings.warn('Not implemented, currently no support for Globus.')
elif tag == 'icon':
# Set up temporary directory for zip files
temp_dir = tempfile.TemporaryDirectory()

# Download using NASA CDAWeb methods in pysatNASA
cdw.download(date_array, tag, inst_id, data_path=temp_dir.name,
cdw.download(date_array, tag=tag, inst_id=inst_id, data_path=data_path,
supported_tags=download_tags)

# Get a list of files in `temp_dir`
dl_files = pysat.Files.from_os(
temp_dir.name, format_str=download_tags[inst_id][tag]['fname'])

# Decompress files
for dl_fname in dl_files.values:
dl_fname = os.path.split(dl_fname)[1]
with zipfile.ZipFile(os.path.join(temp_dir.name, dl_fname),
'r') as open_zip:
open_zip.extractall(data_path)

# Cleanup temporary directory
temp_dir.cleanup()

return


Expand Down
Loading