Converting time zone to Mountain Time

This page shows how to convert time zone from original UTC to Mountain Standard Time.

Merge multiple datasets

When you run the program (here) that reads the original CSV data and generates a timestamp, the original data placed in the yearly directory is redistributed into each station’s directory, as shown below.

_images/folder_info2.png

Now, we will merge multiple files in each directory and create one file at each station directory.

$ cd beaver
$ awk 1 *.csv > UCSRN_Hr_TBL.csv
_images/folder_info3.png

Conversion of local time from UTC

Read CSV data

Check here for how to read the data.

Time conversion

Specify a time lag (-6 hours) in the subroutine that generates the date and time format from the original “days of the year” and “hour” information.

        timestamp = dayofY_toTimeStamp(df,-6) 
def dayofY_toTimeStamp(df,deltt):

    newdate = pd.to_datetime(df.loc[:,'Year'].values*10000000+df.loc[:,'Day_of_Year'].values*10000+df.loc[:,'HrMin'], format='%Y%j%H%M') \
            + pd.Timedelta(hours=deltt)

    return newdate

Note

The time conversion does not include daylight savings time adjustment.

Sample program for creating a new MT dated data set

This program gets a filename under multiple directories (station names) and reads the data in one file in each directory.

_images/folder_info3.png

Source file: convert.MTtime.py