GithubHelp home page GithubHelp logo

rilma / pyhwm14 Goto Github PK

View Code? Open in Web Editor NEW
40.0 5.0 12.0 2.68 MB

Python interface for the Horizontal Wind Model 2014 (HWM14)

License: MIT License

Python 48.75% Fortran 50.99% Makefile 0.26%
atmosphere atmospheric-modelling atmospheric-sciences model f2py

pyhwm14's Introduction

image

image

pyHWM14

Python interface for the Horizontal Wind Model version 2014 (HWM14)

Installation

From Source Code

Currently supports Python 3.10 under Ubuntu 20.04 (see Github Actions).

IMPORTANT: For support in other Python versions and/or OS, users are invited to work on the case and submmit a PR. Help making the project more generic!

$ git clone https://github.com/rilma/pyHWM14.git
$ cd pyHWM14
$ make install

From PyPi

pip install pyhwm2014

Testing

$ make test

Examples

You will need seaborn (the statistical data visualization package) in order to run the following examples.

$ pip install seaborn

Height Profile

>>> from pyhwm2014 import HWM14, HWM14Plot    
>>> hwm14Obj = HWM14( altlim=[90,200], altstp=1, ap=[-1, 35], day=323,
        option=1, ut=11.66667, verbose=False, year=1993 )            
>>> hwm14Gbj = HWM14Plot( profObj=hwm14Obj )

image

You can also list the values on screen as follows

>>> from pyhwm2014 import HWM14
>>> hwm14Obj = HWM14( altlim=[90,200], altstp=10, ap=[-1, 35], day=323,
        option=1, ut=11.66667, verbose=True, year=1993 )

HEIGHT PROFILE
                 quiet         disturbed             total
 alt      mer      zon      mer      zon      mer      zon
  90   11.112   28.727   -0.001   -0.000   11.112   28.726
 100   26.762    6.705   -0.007   -0.006   26.755    6.700
 110  -40.361    1.468   -0.080   -0.066  -40.442    1.402
 120  -15.063  -16.198   -0.777   -0.640  -15.840  -16.838
 130    5.352  -28.597   -2.713   -2.233    2.639  -30.829
 140   -7.310  -28.295   -3.410   -2.806  -10.720  -31.101
 150  -23.281  -26.597   -3.484   -2.867  -26.765  -29.464
 160  -34.557  -20.983   -3.490   -2.872  -38.047  -23.855
 170  -40.041  -13.405   -3.491   -2.872  -43.531  -16.277
 180  -37.589  -12.893   -3.491   -2.872  -41.080  -15.765
 190  -29.611  -18.405   -3.491   -2.872  -33.102  -21.278
 200  -19.680  -26.278   -3.491   -2.872  -23.171  -29.150

Geog. Latitude Profile

>>> from pyhwm2014 import HWM14, HWM14Plot
>>> hwm14Obj = HWM14( alt=130., ap=[-1, 35], day=323, glatlim=[-90.,90.],
        glatstp=1., option=2, ut=11.66667, verbose=False, year=1993 )            
>>> hwm14Gbj = HWM14Plot( profObj=hwm14Obj )

image

GMT Profile

>>> from pyhwm2014 import HWM14, HWM14Plot
>>> hwm14Obj = HWM14( alt=130., ap=[-1, 35], day=323,
        option=3, utlim=[0., 23.45], utstp=.25, verbose=False, year=1993 )            
>>> hwm14Gbj = HWM14Plot( profObj=hwm14Obj )

image

Geog. Longitude Profile

>>> from pyhwm2014 import HWM14, HWM14Plot
>>> hwm14Obj = HWM14( alt=130., ap=[-1, 35], day=323, glonlim=[-180., 180.], glonstp=2.,
        option=4, verbose=False, year=1993 )            
>>> hwm14Gbj = HWM14Plot( profObj=hwm14Obj )

image

Height vs GMT

>>> from pyhwm2014 import HWM142D, HWM142DPlot
>>> hwm14Obj = HWM142D(altlim=[90,200], altstp=2, ap=[-1, 35], 
        option=1, utlim=[0.,23.75], utstp=.25, verbose=False)
>>> hwm14Gbj = HWM142DPlot(profObj=hwm14Obj, zMin=[-75., -100], zMax=[75., 100.])

image

Height vs Geog. Latitude

>>> from pyhwm2014 import HWM142D, HWM142DPlot
>>> hwm14Obj = HWM142D(altlim=[90., 200.], altstp=2., ap=[-1, 35], 
        glatlim=[-90., 90.], glatstp=2., option=2, verbose=False, ut=12.)            
>>> hwm14Gbj = HWM142DPlot(profObj=hwm14Obj, zMin=[-250., -100], zMax=[250., 100.])

image

Height vs Geog. Longitude

>>> from pyhwm2014 import HWM142D, HWM142DPlot
>>> hwm14Obj = HWM142D(altlim=[90., 200.], altstp=1., ap=[-1, 35], 
        glonlim=[-90., 90.], glonstp=2., option=4, ut=12., verbose=False)            
>>> hwm14Gbj = HWM142DPlot(profObj=hwm14Obj, zMin=[-100., -100], zMax=[100., 100.])

image

Geog. Latitude vs Geog. Longitude

>>> from pyhwm2014 import HWM142D, HWM142DPlot
>>> hwm14Obj = HWM142D(alt=130., ap=[-1, 35], glatlim=[-90., 90.], 
        glatstp=1., glonlim=[-180., 180.], glonstp=2., option=6, verbose=False)
>>> hwm14Gbj = HWM142DPlot(profObj=hwm14Obj, zMin=[-150., -150], zMax=[150., 150.])

image

Horizontal Wind Field Map

>>> from pyhwm2014 import HWM142D, HWM142DPlot
>>> hwm14Obj = HWM142D(alt=400., ap=[-1, 35], glatlim=[-90., 90.], glatstp=10., 
        glonlim=[-180., 180.], glonstp=20., option=6, verbose=False)
>>> hwm14Gbj = HWM142DPlot( profObj=hwm14Obj, WF=True, zMin=[-150., -150], 
        zMax=[150., 150.] )

image

References

Wrapping Fortran code

This is for reference, no need to do this as it's done by python setup.py develop

1. The first step is to ask 'f2py' to write the signature of the routine (hwm14.f90) to a description file

$ f2py hwm14.f90 -m hwm14 -h hwm14.pyf

The '-m' flag gives the name the python module should have (hwm14). The '-h' flag tells 'f2py' in which file should write the signature (see file 'hwm14.pyf').

2. 'f2py' recognizes which variables need to be passed in or out. This is done by the command 'intent' added to the declaration of variables.

3. Now everything is ready and the module can be compiled. f2py will try to find a compiler in your path and use it. So all to be typed is

$ f2py -c hwm14.pyf hwm14.f90

'f2py' will write the wrapper files, compile hwm14.f90 and the wrapper files, and link them in a shared object. After this step, one can start Python and load the extension module.

NOTE: To specify a Fortran compiler type by vendor, e.g. ifort (Intel Fortran compiler):

$ f2py -c hwm14.pyf hwm14.f90 --fcompiler=intelem

pyhwm14's People

Contributors

rilma avatar scivision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyhwm14's Issues

Problems with the binary file hwm123114.bin

Hi! I followed the installation available in the Readme and got the pyhwm2014 module installed on my computer. When I import pyhwm2014 on Python (version 3.8), no error appears. However, following the testing you provide in the Readme (coverage run tests/test.py -v), I get an error saying:
image

However, the file hwm123114.bin can be found in the data folder.

I also tried the other example in the Readme running it from Python.
image

I get a similar problem related to the file hwm123114.bin, now saying this:
image

It looks like there is a problem with the hw14.f90 source file. I tried with the last release (2017), the master branch and the version 0.02 and the same happens.

ImportError: DLL load failed while importing hwm14: The specified module could not be found.

Hi, I'm having some trouble getting the module working. I've tried both the pip install and install from source code methods in python 3.10 and python 3.8. Every time the install process runs fine, but when I try the test it gives the following error.

======================================================================
ERROR: test (unittest.loader._FailedTest)

ImportError: Failed to import test module: test
Traceback (most recent call last):
File "C:\Users\mouse\anaconda3\envs\test\lib\unittest\loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "C:\Users\mouse\anaconda3\envs\test\lib\unittest\loader.py", line 377, in get_module_from_name
import(name)
File "C:\Users\mouse\pyHWM14\tests\test.py", line 2, in
from pyhwm2014 import HWM14
File "C:\Users\mouse\pyHWM14\pyhwm2014_init
.py", line 7, in
from . import hwm14
ImportError: DLL load failed while importing hwm14: The specified module could not be found.

In the folder "C:\Users\mouse\pyHWM14\pyhwm2014" there is a file called "hwm14.cp38-win_amd64.pyd" (and a corresponding cp310 file from the python 3.10 install). I think this is the file it should be looking for at this point? But I'm not sure why it's having this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.