# -*- coding: utf-8 -*-
"""Supports the Floating Potential Measurement Unit
(FPMU) instrument onboard the International Space
Station (ISS). Downloads data from the NASA
Coordinated Data Analysis Web (CDAWeb).

Parameters
----------
platform : string
    'iss'
name : string
    'fpmu'
tag : string
    None Supported
sat_id : string
    None supported

Warnings
--------
- Currently clean only replaces fill values with Nans.
- Module not written by FPMU team.

"""
from __future__ import print_function
from __future__ import absolute_import
import datetime as dt
import functools
import numpy as np

from pysat.instruments.methods import general as mm_gen
from pysat.instruments.methods import nasa_cdaweb as cdw

platform = 'iss'
name = 'fpmu'
tags = {'': ''}
sat_ids = {'': ['']}
_test_dates = {'': {'': dt.datetime(2017, 10, 1)}}

# support list files routine
# use the default CDAWeb method
fname = 'iss_sp_fpmu_{year:04d}{month:02d}{day:02d}_v01.cdf'
supported_tags = {'': {'': fname}}
list_files = functools.partial(mm_gen.list_files,
                               supported_tags=supported_tags)
# support load routine
# use the default CDAWeb method
load = cdw.load

# support download routine
# use the default CDAWeb method
basic_tag = {'dir': '/pub/data/international_space_station_iss/sp_fpmu',
             'remote_fname': '{year:4d}/' + fname,
             'local_fname': fname}
supported_tags = {'': {'': basic_tag}}
download = functools.partial(cdw.download, supported_tags)

# support listing files currently on CDAWeb
list_remote_files = functools.partial(cdw.list_remote_files,
                                      supported_tags=supported_tags)


def clean(inst):
    """Return FPMU data cleaned to the specified level.

    Parameters
    ----------
    inst : (pysat.Instrument)
        Instrument class object, whose attribute clean_level is used to return
        the desired level of data selectivity.

    Returns
    -------
    Void : (NoneType)
        data in inst is modified in-place.

    """

    inst.data.replace(-999., np.nan, inplace=True)  # Te
    inst.data.replace(-9.9999998e+30, np.nan, inplace=True)  # Ni

    return None

@@ -576,16 +576,31 @@
 nctools%0A
+import logging%0A
 import n
@@ -610,16 +610,16 @@
 y as np%0A
-
 %0Afrom py
@@ -725,16 +725,54 @@
 as cdw%0A%0A
+logger = logging.getLogger(__name__)%0A%0A
 platform
@@ -1638,32 +1638,32 @@
 t_remote_files,%0A
-
                 
@@ -1717,16 +1717,1498 @@
 tags)%0A%0A%0A
+def init(self):%0A    %22%22%22Initializes the Instrument object with instrument specific values.%0A%0A    Runs once upon instantiation.%0A%0A    Parameters%0A    ----------%0A    inst : pysat.Instrument%0A        Instrument class object%0A%0A    %22%22%22%0A%0A    ackn_str = ' '.join(('Data provided through NASA CDAWeb.  Contact',%0A                         'Rob.Suggs@nasa.gov for support and use.'))%0A    logger.info(ackn_str)%0A    self.meta.acknowledgements = ackn_str%0A    self.meta.references = ' '.join(('V. N. Coffey et al., %22Validation of the',%0A                                     'Plasma Densities and Temperatures From',%0A                                     'the ISS Floating Potential Measurement',%0A                                     'Unit,%22 in IEEE Transactions on Plasma',%0A                                     'Science, vol. 36, no. 5, pp. 2301-2308,',%0A                                     'Oct. 2008,',%0A                                     'doi: 10.1109/TPS.2008.2004271.%5Cn',%0A                                     'A. Barjatya, C.M. Swenson, D.C.',%0A                                     'Thompson, and K.H. Wright Jr., Data',%0A                                     'analysis of the Floating Potential',%0A                                     'Measurement Unit aboard the',%0A                                     'International Space Station, Rev. Sci.',%0A                                     'Instrum. 80, 041301 (2009),',%0A                                     'https://doi.org/10.1063/1.3116085'))%0A%0A    return%0A%0A%0A
 def clea

add fpmu