{ "info": { "author": "Carmelo Sammarco", "author_email": "sammarcocarmelo@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering" ], "description": "# tool4NC\n\n[![Build Status](https://travis-ci.com/carmelosammarco/tool4nc.png)](https://travis-ci.com/carmelosammarco/tool4nc) [![Build status](https://ci.appveyor.com/api/projects/status/58ppa5otfl06rd1h?svg=true)](https://ci.appveyor.com/project/carmelosammarco/tool4nc) [![PyPi](https://img.shields.io/badge/PyPi-Project-yellow.svg)](https://pypi.org/project/tool4nc/) [![Gitter](https://badges.gitter.im/tool4nc/community.svg)](https://gitter.im/tool4nc/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n\nI developed this software while working as [AKKA](https://www.akka-technologies.com) consultant engeneer for the [CMEMS's Service Desk (Copernicus Marine Environment Monitoring Service)](http://marine.copernicus.eu). I was and I am inspired by the Mercator-Ocean's community (users, co-workers, web-forum discussions and many more) which gave me ideas and the motivational power to build this tool. It is the first python application of its kind created inside the CMEMS environment and I hope that with time it will became an ufficial CMEMS tool. The main goals that I wanted to adress were solving the most common user problems as the data-download requests and the netCDF file manipulations.\n\n**This project gave me also ideas to develop other tools** as [MerOC](https://github.com/carmelosammarco/MerOC), [MerocENV](https://github.com/carmelosammarco/MerocENV) and [ads4MO](https://github.com/carmelosammarco/ads4MO). To know more about them just visit the projects web pages which are hyperlinked above.\n\nI created also a **chat-community** powered by \"Gitter\" where is possible have an exchange of ideas,functionalities,bugs and many more. Just click ![Gitter](https://badges.gitter.im/tool4nc/community.svg) to acces the chat room.\n\nMany thanks to visit this page and try this software.\n\n**Carmelo Sammarco**\n\n## Introduction:\nPython module containing functions for simplifing the netCDF files manipulations.\n\n## Be aware that:\n\nThe tool is in development so it can be possible find bugs, errors and imprecisions. Please to report them if you find one.\n\n## Dependencies:\n\nThe dependencies required are listed below:\n\n- [x] netCDF4>=1.4.2\n- [x] csv342>=1.0.0 \n- [x] pandas>=0.23.4 \n- [x] xarray>=0.11.0 \n- [x] Shapely>=1.6.4.post1\n- [x] Fiona>=1.8.4\n- [x] cdo>=1.4.0\n\n\n## Installation for Unix users (Linux distros and Mac-OSX systems):\n\nAs first things please install [cdo - climate data operator](https://code.mpimet.mpg.de/projects/cdo). It is required to run few functions contained in the python module. You can use the following command:\n\n```\nsudo apt-get install cdo\n```\n\nAlso please consider to install [Anaconda](https://www.anaconda.com) 3.* version (Be aware that to use this software is suggested python ~=3.6). Once the Anaconda bash file (.sh) is downloaded, you can execute it in the terminal using the following command:\n\n```\nbash file_installation_Anaconda_downloaded.sh\n```\n\n Furthermore, an update of pip, setuptools and wheels is suggested. You can do it executing the following command:\n\n```\npython -m pip install --upgrade pip setuptools wheel\n```\n\nAfter that run the software installation with:\n\n```\npip install tool4NC\n```\n\n## Installation for Windows users:\n\nAs first things please install [cdo - climate data operator](https://code.mpimet.mpg.de/projects/cdo). It is required to run few functions inside the \"TAB2:netCDF-Manipulations\". From the product web page you can download the version which satisfy your system characteristics. Once de-compressed the folder downloaded just run the .exe file to install cdo in your Windows OS system.\n\nAlso please consider to install [Anaconda](https://www.anaconda.com) 3.* version (Be aware that to use this software is suggested python ~=3.6). The file from you downloaded will be a stardard executable (.exe). Before run the installation please be sure to tick the option for add in the Windows PATH environment variable the path of the anaconda package. \n\nFurthermore, an update of pip, setuptools and wheels is suggested. You can do it executing the following command:\n\n```\npython -m pip install --upgrade pip setuptools wheel\n```\n\nBefore start with the python module installlation it is mandatory to manually configure and install few python dependencies that are not correctly managed by the stardard 'pip' Windows installation. The dependencies that I am speaking of are \u201cshapely\u201d and \u201cfiona\u201d. They are essential Python modules for geospatial operations contained in this python package (exporting a netCDF variable as shapefile just to cite one). In this particular scenario, and especially in a Windows OS, be able to install the required modules using the Python wheels can be very handy. In fact they are already pre-compiled and then easily digested from the Windows OS. Christoph Gohlke, at the Laboratory for Fluorescence Dynamics at UC Irvine, maintains a large [Python wheels library](https://www.lfd.uci.edu/~gohlke/pythonlibs/). Be aware that for each module you need to choose the one maching your Python version and the pc processor characteristics (32 or 64-bit). If we consider as example \"Shapely-1.6.4.post1-cp37-cp37m-win32.whl\" the \"cp37\" indicate the python version which is 3.7.* while \"win32\" the processor type which is 32-bit. The python version can be indicated also as \"py3\" or \"py2\" or \"py2.py3\". the latter when both the 2.* and 3.* python version can be used. To install a wheel file you just need to run \"pip install [wheel_file]\" in the same location where the wheel is located. To succeed within the installation of \"shapely\" and \"fiona\" you must execute the following steps, in the same order as they are listed below:\n\n1. Install [Visual studio C++](https://www.microsoft.com/en-us/download/details.aspx?id=48145).\n \n2. Download [gdal](https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal), [click](https://www.lfd.uci.edu/~gohlke/pythonlibs/#click), [cligj](https://www.lfd.uci.edu/~gohlke/pythonlibs/#cligj), [click_plugin](https://www.lfd.uci.edu/~gohlke/pythonlibs/#click), [attrs](https://www.lfd.uci.edu/~gohlke/pythonlibs/#attrs), [munch](https://www.lfd.uci.edu/~gohlke/pythonlibs/#munch), [fiona](https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona), [pyproj](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj), [rtree](https://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree) and [shapely](https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely) from the [Python wheels library](https://www.lfd.uci.edu/~gohlke/pythonlibs/). Now you have what you need for the following steps.\n\n3. Install the gdal wheel. I suggest you to don't use gdal module alongside OSGeo4W or other similar distributions because they could go in conflict and then generate errors and malfuctions. Also add the gdal library path to the Windows PATH environment variable (which will be something like \"C:\\pyhon_version\\Lib\\site-packages\\osgeo\".To know in which way add the gdal path variable you can check [here](https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/). Finally we can now test the gdal module. Before do that please to close and then re-open the command prompt and from whatever path location execute this command:\n\n```\ngdalinfo --help-general\n```\n \nIf gdal is correctly configured it will display its usage instructions.\n \n4. Install the others Python wheels modules, previously downloaded (gdal excluded), and following the list order (from the top to the bottom):\n\n- click\n- cligj\n- click plugin\n- attrs\n- munch\n- fiona\n- pyproj\n- rtree\n- shapely\n\nNow that the all the most nasty dependencies are installed (at least for Windows OS), you can execute:\n\n```\npip install tool4NC\n```\nAt this point, after the installation you are ready to import the tool4nc module as:\n\n```\nfrom tool4NC import * ---> #Import all the fuctions\nfrom tool4NC import [name_fuction] ---> #Import just one fuction \n```\nFor the list of fucntions avaiable a in \"tool4nc\" module please continue to read below.\n\n## Functions included:\n\n\n### nctocsv (\"input file\", \"path_output folder\")\n\nThis function converts a netCDF file to a csv file. It will generate two csv files called file.csv and file_cleaned.csv respectively. The file_cleaned.csv is cleaned by all the NAN values and it is considered the final output file of this function.\n\n\n### nctoshape (\"input file\", \"path_output folder\", \"variable_name\")\n\nThis function converts a netCDF file into a shape file (Point features). Firstly, it will generate two csv files called file.csv and file_cleaned.csv respectively. After that, the file_cleaned.csv (purified by all the NAN values) is used to extract the corresponding shapefile representing a variable\u2019s values which is the third argument of this function.\n\n### nctogdr (\"input file\", \"path_output folder\")\n\nThis fuction convert a netCDF file to a GRD file which is required for some computations.\n\n\n### concatnc (\"path_input folder\")\n\nThis function is qble to concatenate segments of data coming from the same dataset but at different time steps. It will generate a file called \"concatenated.nc\" as final result. The only argument needed is the folder where the files are located.\n\n\n### splitnc (\"input file\", \"path_output folder\", \"type\", \"suffix\")\n\nThis function can split the data by type; DAY (DD), MONTH (YYYYMM) and YEAR (YYYY). It gives the option to add a suffix to the generated data. \n\n\n# Case examples:\n\n## I have many netCDF files and I would like to convert all of them in CSV: \n\n```\nimport os\nfrom tool4NC import nctocsv\n\nInput_DIR = 'the/directory/you/want/to/use'\nOut_DIR = 'the/directory/you/want/to/use'\n\nfor filename in os.listdir(Input_DIR):\n if filename.endswith(\".nc\"):\n nctocsv (filename, Out_DIR)\n```\n\n## I want to overlay in my GIS project (as shape-file) data from a variable which is contained in my netCDF file:\n\n```\nimport os\nfrom tool4NC import nctoshape\n\nInput_DIR = 'the/directory/you/want/to/use'\nOut_DIR = 'the/directory/you/want/to/use'\nVariable = \u2018Variable name\u2019\n\nfor filename in os.listdir(Input_DIR):\n if filename.endswith(\".nc\"):\n nctoshape (filename, Out_DIR, Variable)\n```\n\n## I have a folder with a month of data divided in daily files. These files are downloaded from the same dataset and I would like to concatenate all the daily files in a montly one:\n\n```\nfrom tool4NC import concatnc\n\nInput_DIR = 'the/directory/where/you/store/the/daily/file'\n\nconcatnc (Input_DIR) #it will generate the concatenated.nc file\n```\n\n## I have many netCDF files and I would like to convert all of them in GRD: \n\n```\nimport os\nfrom tool4NC import nctogrd\n\nInput_DIR = 'the/directory/you/want/to/use'\nOut_DIR = 'the/directory/you/want/to/use'\n\nfor filename in os.listdir(Input_DIR):\n if filename.endswith(\".nc\"):\n nctogdr (filename, Out_DIR)\n```\n\n## I have one year file but i realised that it is better have the data organised by Month. Furthermore, I would like also add a suffix to each file:\n\n```\nfrom tool4NC import splitnc\n\nInput_file = 'my_input_file.nc'\nOut_DIR = 'the/directory/you/want/to/output/the/results'\ntype = \"MONTH\"\nsuffix = \"text/to/append/at/each/file\"\n\n\nsplitnc (Input_file, Out_DIR, type, suffix)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/carmelosammarco/tool4nc", "keywords": "", "license": "gpl-3.0", "maintainer": "", "maintainer_email": "", "name": "tool4NC", "package_url": "https://pypi.org/project/tool4NC/", "platform": "", "project_url": "https://pypi.org/project/tool4NC/", "project_urls": { "Homepage": "https://github.com/carmelosammarco/tool4nc" }, "release_url": "https://pypi.org/project/tool4NC/0.0.3/", "requires_dist": null, "requires_python": "~=3.6", "summary": "Python module for the netCDF files manipulations", "version": "0.0.3" }, "last_serial": 5782381, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "1cd8fbb1c1cbdecf658df33e2b101522", "sha256": "5df531928a619700bf06fa85ac7748fb311386a4984a020c2d6a2178a2546c0e" }, "downloads": -1, "filename": "tool4NC-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1cd8fbb1c1cbdecf658df33e2b101522", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 7989, "upload_time": "2019-09-04T16:44:16", "url": "https://files.pythonhosted.org/packages/74/8b/dab9b98977b48cc85f8d9a30346682281b52f1742951f8de0998c931c1c9/tool4NC-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1cd8fbb1c1cbdecf658df33e2b101522", "sha256": "5df531928a619700bf06fa85ac7748fb311386a4984a020c2d6a2178a2546c0e" }, "downloads": -1, "filename": "tool4NC-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1cd8fbb1c1cbdecf658df33e2b101522", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 7989, "upload_time": "2019-09-04T16:44:16", "url": "https://files.pythonhosted.org/packages/74/8b/dab9b98977b48cc85f8d9a30346682281b52f1742951f8de0998c931c1c9/tool4NC-0.0.3.tar.gz" } ] }