def read_solrad(filename):
if '<STR_LIT>' in filename:<EOL><INDENT>names = MADISON_HEADERS<EOL>widths = MADISON_WIDTHS<EOL>dtypes = MADISON_DTYPES<EOL><DEDENT>else:<EOL><INDENT>names = HEADERS<EOL>widths = WIDTHS<EOL>dtypes = DTYPES<EOL><DEDENT>data = pd.read_fwf(filename, header=None, skiprows=<NUM_LIT:2>, names=names,<EOL>widths=widths, na_values=-<NUM_LIT>)<EOL>for (col, _dtype) in zip(data.columns, dtypes):<EOL><INDENT>ser = data[col].astype(_dtype)<EOL>if _dtype == '<STR_LIT>':<EOL><INDENT>ser = ser.where(ser > -<NUM_LIT>, other=np.nan)<EOL><DEDENT>data[col] = ser<EOL><DEDENT>dts = data[['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']].astype(str).apply(<EOL>lambda x: x.str.zfill(<NUM_LIT:2>))<EOL>dtindex = pd.to_datetime(<EOL>data['<STR_LIT>'].astype(str) + dts['<STR_LIT>'] + dts['<STR_LIT>'] + dts['<STR_LIT>'] +<EOL>dts['<STR_LIT>'], format='<STR_LIT>', utc=True)<EOL>data = data.set_index(dtindex)<EOL>try:<EOL><INDENT>data = data.tz_localize('<STR_LIT>')<EOL><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>return data<EOL>
Read NOAA SOLRAD [1]_ [2]_ fixed-width file into pandas dataframe.

Parameters
----------
filename: str
    filepath or url to read for the fixed-width file.

Returns
-------
data: Dataframe
    A dataframe with DatetimeIndex and all of the variables in the
    file.

Notes
-----
SOLRAD data resolution is described by the README_SOLRAD.txt:
"Before 1-jan. 2015 the data were reported as 3-min averages;
on and after 1-Jan. 2015, SOLRAD data are reported as 1-min.
averages of 1-sec. samples."
Here, missing data is flagged as NaN, rather than -9999.9.

References
----------
.. [1] NOAA SOLRAD Network
   `https://www.esrl.noaa.gov/gmd/grad/solrad/index.html
   <https://www.esrl.noaa.gov/gmd/grad/solrad/index.html>`_

.. [2] B. B. Hicks et. al., (1996), The NOAA Integrated Surface
   Irradiance Study (ISIS). A New Surface Radiation Monitoring
   Program. Bull. Amer. Meteor. Soc., 77, 2857-2864.
   :doi:`10.1175/1520-0477(1996)077<2857:TNISIS>2.0.CO;2`