-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2019 Satpy developers | ||
# | ||
# This file is part of satpy. | ||
# | ||
# satpy is free software: you can redistribute it and/or modify it under the | ||
# terms of the GNU General Public License as published by the Free Software | ||
# Foundation, either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# satpy is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# satpy. If not, see <http://www.gnu.org/licenses/>. | ||
"""Earth Networks Total Lightning Network Dataset reader | ||
With over 1,700 sensors covering over 100 countries around the world, | ||
ENTLN is the most extensive and technologically-advanced global lightning network. | ||
The data provided is generated by the ENTLN worker. | ||
References: | ||
- [ENTLN] https://www.earthnetworks.com/why-us/networks/lightning | ||
""" | ||
|
||
import logging | ||
import pandas as pd | ||
import dask.array as da | ||
import xarray as xr | ||
from datetime import datetime | ||
|
||
from satpy import CHUNK_SIZE | ||
from satpy.readers.file_handlers import BaseFileHandler | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ENTLNFileHandler(BaseFileHandler): | ||
"""ASCII reader for Vaisala GDL360 data.""" | ||
|
||
def __init__(self, filename, filename_info, filetype_info): | ||
super(ENTLNFileHandler, self).__init__(filename, filename_info, filetype_info) | ||
|
||
names = ['type', 'timestamp', 'latitude', 'longitude', 'peakcurrent', \ | ||
'icheight', 'numbersensors', 'icmultiplicity', 'cgmultiplicity', \ | ||
'starttime', 'endtime', 'duration', 'ullatitude', 'ullongitude', \ | ||
'lrlatitude', 'lrlongitude'] | ||
types = ['int', 'str', 'float', 'float', 'float', \ | ||
'float', 'int', 'int', 'int', \ | ||
'str', 'str', 'float', 'float', 'float', \ | ||
'float', 'float'] | ||
dtypes = dict(zip(names, types)) | ||
|
||
self.data = pd.read_csv(filename, delimiter=',', dtype=dtypes, parse_dates=['timestamp'], skipinitialspace=True) | ||
|
||
@property | ||
def start_time(self): | ||
return self.data['timestamp'].index[0] | ||
#return self.data['timestamp'][0] #cldn | ||
|
||
@property | ||
def end_time(self): | ||
#return self.data['timestamp'].index[-1] | ||
return self.data['timestamp'].index[-1] #cldn | ||
|
||
def get_dataset(self, dataset_id, dataset_info): | ||
"""Load a dataset.""" | ||
xarr = xr.DataArray(da.from_array(self.data[dataset_id.name], | ||
chunks=CHUNK_SIZE), dims=['y'])#dataset_id.name]) | ||
|
||
# Add variables as non-dimensional y-coordinates | ||
for column in ['type', 'timestamp', 'latitude', 'longitude']:#self.data.columns: | ||
xarr[column] = ('y', self.data[column])#dataset_id.name, self.data[column]) | ||
xarr.attrs.update(dataset_info) | ||
|
||
return xarr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
reader: | ||
description: Earth Networks Total Lightning Network Dataset reader | ||
name: entln | ||
reader: !!python/name:satpy.readers.yaml_reader.FileYAMLReader '' | ||
sensors: [entln] | ||
|
||
file_types: | ||
entln: | ||
file_reader: !!python/name:satpy.readers.entln.ENTLNFileHandler '' | ||
file_patterns: ['LtgFlashPortions{date:%Y%m%d}.csv'] | ||
|
||
datasets: | ||
datetime: | ||
name: datetime | ||
sensor: entln | ||
file_type: entln | ||
|
||
latitude: | ||
name: latitude | ||
sensor: entln | ||
file_type: entln | ||
standard_name: latitude | ||
units: degree_north | ||
|
||
longitude: | ||
name: longitude | ||
sensor: entln | ||
file_type: entln | ||
standard_name: longitude | ||
units: degree_east | ||
|
||
type: | ||
name: type | ||
sensor: entln | ||
file_type: entln | ||
coordinates: | ||
- longitude | ||
- latitude | ||
units: "1" | ||
standard_name: type | ||
|
||
timestamp: | ||
name: timestamp | ||
sensor: entln | ||
file_type: entln | ||
coordinates: | ||
- longitude | ||
- latitude | ||
standard_name: timestamp | ||
|
||
# peakcurrent: | ||
# name: peakcurrent | ||
# sensor: entln | ||
# resolution: 2000 | ||
# file_type: entln | ||
# coordinates: | ||
# - longitude | ||
# - latitude | ||
# units: kA | ||
# standard_name: peakcurrent |