Skip to content

This class converts and joins netcdf files from the Tall Tower database into a csv file

Notifications You must be signed in to change notification settings

marcosp-araujo/Tower2csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

The Tall Tower is an open database aimed at boosting the use of hub-height wind observations from meteorological towers. The Tower2csv.py class scans netCDF files from a Tall Tower database and joins all of them into a single .CSV file.

Requirements and virtual environment

Creating a virtual environment is strongly advisable to avoid errors when running the Tower2csv. It can be done using the "virtualenv" library. Use the following command lines in your terminal to install "virtualenv" and configurate a new virtual environment:

pip install virtualenv

For creating a new virtual environment called "venv":

python -m venv venv

Now, for activating the new virtual environment:

.\venv\Scripts\activate

Then, for installing the requirements.txt:

pip install -r requirements.txt

How to use

In the main.py script you can set the netCDF files directory and the name of the output .csv file. Example data can be found in the owez folder.

from modules.Tower2csv import Tower2csv

if __name__ == "__main__":
   
    netcdf_dir = r".\owez\10minutely" # directory of the netCDF files
    save_file_path = r".\owez"        # directory to save the .csv file

    T = Tower2csv(netcdf_dir, save_file_path)

Once the new environment is activated, you can run the Tower2csv by this simple command line call:

python .\main.py 

Input parameters

The Tower2csv requires two inputs:

  • netcdf_dir = Directory of the netCDF files (string).

  • save_file_path = Name of the .CSV file where the output data will be saved (string).

Input data example

Data from the OWEZ offshore meteorological tower are used to exemplify the Tower2csv applicability (owez). You can find data from other sites at the following link:

https://talltowers.bsc.es/access-the-data

Input database structure

Now, let's continue by understanding the dataset structure using the data example which is uploaded here. When opening the owez folder, there is a subfolder called 10minutely:

image

The data are organized in different subfolders inside 10minutely, which are named according to the sensor type:

image

For instance, in the humidity-sensor folder "huragl116S1", you will see that there is one netCDF file for each month:

image

Output example

One output example is in owez.csv. When running the Tower2csv.py via main.py, all netCDF files from all subfolders are joined, and then, saved into a single .CSV file. Data from each sensor are stored in different comma-separated columns as follows:

image

About

This class converts and joins netcdf files from the Tall Tower database into a csv file

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages