Compare commits

...

8 Commits

@ -1,2 +0,0 @@
# Ignore folder content
tests/*

@ -1,20 +0,0 @@
engines:
duplication:
enabled: true
- mass = 50
config:
languages:
python:
mass_threshold: 40
fixme:
enabled: true
radon:
enabled: true
ratings:
paths:
- "**.py"
exclude_paths:
- wafo/tests/
- wafo/MSPPT.py
- wafo/MSO.py

@ -1,25 +0,0 @@
# .coveragerc to control coverage.py
[run]
branch = True
source = wafo
omit =
tests/*
source/*
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about missing debug-only code:
def __repr__
if self\.debug
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

42
.gitignore vendored

@ -1,42 +0,0 @@
# Temporary and binary files
*~
*.py[cod]
*.so
*.cfg
!setup.cfg
*.orig
*.log
*.pot
__pycache__/*
.cache/*
.*.swp
*.mod
# Project files
.ropeproject
.project
.pydevproject
.settings
.idea
# Package files
*.egg
*.eggs/
.installed.cfg
*.egg-info
# Unittest and coverage
htmlcov/*
.coverage
.tox
junit.xml
coverage.xml
# Build and docs folder/files
build/*
dist/*
sdist/*
docs/_rst/*
docs/_build/*
cover/*
MANIFEST

@ -1,23 +0,0 @@
doc-warnings: yes
test-warnings: no
strictness: high
pylint:
disable:
- too-few-public-methods
- no-self-use
- too-many-instance-attributes
- invalid-name
- missing-docstring
- star-args
- logging-format-interpolation
- bad-builtin
ignore-paths:
- docs
pep8:
disable:
- E731
- E126
- E128
- E115
- N802

@ -1,400 +0,0 @@
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Pickle collected data for later comparisons.
persistent=yes
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers. (PAB)
load-plugins=pylint.extensions.mccabe
# Maximum threshold for cyclomatic complexity (PAB)
max-complexity=10
# (PAB)
consider-iterating-dictionary=yes
# Use multiple processes to speed up Pylint.
jobs=1
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code (PAB)
extension-pkg-whitelist=numpy
# Allow optimization of some AST trees. This will activate a peephole AST
# optimizer, which will apply various small optimizations. For instance, it can
# be used to obtain the result of joining multiple strings with the addition
# operator. Joining a lot of strings can lead to a maximum recursion error in
# Pylint and this flag can prevent that. It has one side effect, the resulting
# AST will be different than the one from reality. This option is deprecated
# and it will be removed in Pylint 2.0.
optimize-ast=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
#enable=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=locally-disabled
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,W0201
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html. You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=parseable
# output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]". This option is deprecated
# and it will be removed in Pylint 2.0.
files-output=no
# Tells whether to display a full report or only the messages
reports=yes
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=
[BASIC]
# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,input
# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,m,n,ex, Run, _, x, y, z, u, v, w, a, b, c, f, g, h, p, q, r, s, t
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Include a hint for the correct naming format with invalid-name
#include-naming-hint=no
include-naming-hint=yes
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty
# Regular expression matching correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$
# Naming hint for function names
function-name-hint=[a-z_][a-z0-9_]{2,30}$
# Regular expression matching correct variable names
variable-rgx=[a-z_][a-z0-9_]{2,30}$
# Naming hint for variable names
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
# Regular expression matching correct dummy-variable names (PAB)
dummy-variables-rgx=^_
# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Regular expression matching correct attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$
# Naming hint for attribute names
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
# Regular expression matching correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}$
# Naming hint for argument names
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
# Regular expression matching correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$
# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression matching correct method names
method-rgx=[a-z_][a-z0-9_]{2,30}$
# Naming hint for method names
method-name-hint=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
[ELIF]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=100
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator
# Maximum number of lines in a module
max-module-lines=1000
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
[LOGGING]
# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=4
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=no
[SPELLING]
# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no
[TYPECHECK]
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,_fields,_replace,_source,_make
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of branch for function / method body
max-branches=12
# Maximum number of statements in function / method body
max-statements=50
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
[IMPORTS]
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=regsub,TERMIOS,Bastion,rexec
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

@ -1,61 +0,0 @@
# Travis configuration file using the build matrix feature
# Read more under http://docs.travis-ci.com/user/build-configuration/
# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS!
sudo: true
language: python
python:
- 2.7
# - 3.4 # Drop support for python 3.4
- 3.5
- 3.6
notifications:
email: false
# Setup anaconda
before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- chmod +x miniconda.sh
- ./miniconda.sh -b
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
export PATH=/home/travis/miniconda2/bin:$PATH;
else
export PATH=/home/travis/miniconda3/bin:$PATH;
fi
- conda update --yes conda
- conda install --yes conda-build
- conda create --yes -n condaenv python=$TRAVIS_PYTHON_VERSION
- conda install --yes -n condaenv pip
- conda config --add channels https://conda.anaconda.org/omnia
- conda config --add channels https://conda.anaconda.org/pbrod
- source activate condaenv
- sudo apt-get update
- sudo apt-get install gfortran
# Install packages
install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy nose pytest matplotlib pytest-pep8 pytest-cov mpmath pillow numba statsmodels
- pip install funcsigs
- pip install numdifftools
- pip install coveralls
- pip install codecov
- python setup.py build
- python setup.py install
# - conda build conda_recipe
# - conda install wafo --use-local
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- git config --global user.email "per.andreas.brodtkorb@gmail.com"
- git config --global user.name "pbrod"
script:
- coverage run --source=wafo setup.py test
# - py.test wafo --cov --pep8 --doctest-modules
after_success:
- coveralls
- codecov
cache:
- apt

@ -1,8 +0,0 @@
==========
Developers
==========
* Per A. Brodtkorb
* Georg Lindgren
* David Verelst

@ -1,11 +0,0 @@
=========
Changelog
=========
Version 0.1
===========
- Feature A added
- FIX: nasty bug #1729 fixed
- add your changes here!

@ -1,131 +0,0 @@
environment:
global:
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
matrix:
# Python 2.7.10 is the latest version and is not pre-installed.
- PYTHON: "C:\\Python27.10"
PYTHON_VERSION: "2.7.10"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python27.10-x64"
PYTHON_VERSION: "2.7.10"
PYTHON_ARCH: "64"
# Pre-installed Python versions, which Appveyor may upgrade to
# a later point release.
# See: http://www.appveyor.com/docs/installed-software#python
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x" # currently 2.7.9
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x" # currently 2.7.9
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python33"
PYTHON_VERSION: "3.3.x" # currently 3.3.5
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python33-x64"
PYTHON_VERSION: "3.3.x" # currently 3.3.5
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4.x" # currently 3.4.3
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python34-x64"
PYTHON_VERSION: "3.4.x" # currently 3.4.3
PYTHON_ARCH: "64"
# Python versions not pre-installed
# Python 2.6.6 is the latest Python 2.6 with a Windows installer
# See: https://github.com/ogrisel/python-appveyor-demo/issues/10
- PYTHON: "C:\\Python266"
PYTHON_VERSION: "2.6.6"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python266-x64"
PYTHON_VERSION: "2.6.6"
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.0"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.0"
PYTHON_ARCH: "64"
# Major and minor releases (i.e x.0.0 and x.y.0) prior to 3.3.0 use
# a different naming scheme.
- PYTHON: "C:\\Python270"
PYTHON_VERSION: "2.7.0"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python270-x64"
PYTHON_VERSION: "2.7.0"
PYTHON_ARCH: "64"
install:
- ECHO "Filesystem root:"
- ps: "ls \"C:/\""
- ECHO "Installed SDKs:"
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
# Install Python (from the official .msi of http://python.org) and pip when
# not already installed.
- ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }
# Prepend newly installed Python to the PATH of this build (this cannot be
# done from inside the powershell script as it would require to restart
# the parent CMD process).
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
# Check that we have the expected version and architecture for Python
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
# Upgrade to the latest version of pip to avoid it displaying warnings
# about it being out of date.
- "pip install --disable-pip-version-check --user --upgrade pip"
# Install the build dependencies of the project. If some dependencies contain
# compiled extensions and are not provided as pre-built wheel packages,
# pip will build them from source using the MSVC compiler matching the
# target Python version and architecture
- "%CMD_IN_ENV% pip install -r requirements.txt"
build_script:
# Build the compiled extension
- "%CMD_IN_ENV% python setup.py build"
test_script:
# Run the project tests
- "%CMD_IN_ENV% python setup.py test"
after_test:
# If tests are successful, create binary packages for the project.
- "%CMD_IN_ENV% python setup.py bdist_wheel"
- "%CMD_IN_ENV% python setup.py bdist_wininst"
- "%CMD_IN_ENV% python setup.py bdist_msi"
- ps: "ls dist"
artifacts:
# Archive the generated packages in the ci.appveyor.com build report.
- path: dist\*
#on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse
#

@ -1 +0,0 @@
collect_ignore = ["setup.py", "build_all.py"]

@ -1,177 +0,0 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pywafo.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pywafo.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $HOME/.local/share/devhelp/pywafo"
@echo "# ln -s $(BUILDDIR)/devhelp $HOME/.local/share/devhelp/pywafo"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

@ -1,2 +0,0 @@
.. _authors:
.. include:: ../AUTHORS.rst

@ -1,2 +0,0 @@
.. _changes:
.. include:: ../CHANGES.rst

@ -1,238 +0,0 @@
# -*- coding: utf-8 -*-
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import inspect
from sphinx import apidoc
__location__ = os.path.join(os.getcwd(), os.path.dirname(
inspect.getfile(inspect.currentframe())))
package = "wafo"
namespace = []
namespace_pkg = ".".join([namespace[-1], package]) if namespace else package
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage',
'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.pngmath']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'pywafo'
copyright = u'2015, davidovitch'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '' # Is set by calling `setup.py docs`
# The full version, including alpha/beta/rc tags.
release = '' # Is set by calling `setup.py docs`
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
try:
from namespace_pkg import __version__ as version
except ImportError:
pass
else:
release = version
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = ""
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_domain_indices = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'wafo-doc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'user_guide.tex', u'pywafo Documentation',
u'davidovitch', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = ""
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# If true, show page references after internal links.
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_domain_indices = True
# -- External mapping ------------------------------------------------------------
python_version = '.'.join(map(str, sys.version_info[0:2]))
intersphinx_mapping = {
'sphinx': ('http://sphinx.pocoo.org', None),
'python': ('http://docs.python.org/' + python_version, None),
'matplotlib': ('http://matplotlib.sourceforge.net', None),
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'sklearn': ('http://scikit-learn.org/stable', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
}

@ -1,45 +0,0 @@
======
pywafo
======
This is the documentation of **pywafo**.
.. note::
This is the main page of your project's `Sphinx <http://sphinx-doc.org/>`_
documentation. It is formatted in `reStructuredText
<http://sphinx-doc.org/rest.html>`__. Add additional pages by creating
rst-files in ``docs`` and adding them to the `toctree
<http://sphinx-doc.org/markup/toctree.html>`_ below. Use then
`references <http://sphinx-doc.org/markup/inline.html>`__ in order to link
them from this page, e.g. :ref:`authors <authors>` and :ref:`changes`.
It is also possible to refer to the documentation of other Python packages
with the `Python domain syntax
<http://sphinx-doc.org/domains.html#the-python-domain>`__. By default you
can reference the documentation of `Sphinx <http://sphinx.pocoo.org>`__,
`Python <http://docs.python.org/>`__, `matplotlib
<http://matplotlib.sourceforge.net>`__, `NumPy
<http://docs.scipy.org/doc/numpy>`__, `Scikit-Learn
<http://scikit-learn.org/stable>`__, `Pandas
<http://pandas.pydata.org/pandas-docs/stable>`__, `SciPy
<http://docs.scipy.org/doc/scipy/reference/>`__. You can add more by
extending the ``intersphinx_mapping`` in your Sphinx's ``conf.py``.
Contents
========
.. toctree::
:maxdepth: 2
License <license>
Authors <authors>
Changelog <changes>
Module Reference <api/modules>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -1,7 +0,0 @@
.. _license:
=======
License
=======
.. literalinclude:: ../LICENSE.txt

@ -1,110 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup file for wafo.
This file was generated with PyScaffold 2.4.2, a tool that easily
puts up a scaffold for your new Python project. Learn more under:
http://pyscaffold.readthedocs.org/
Usage:
Run all tests:
python setup.py test
python setup.py doctests
Build documentation
python setup.py docs
Install
python setup.py install [, --prefix=$PREFIX]
Build
python setup.py bdist_wininst
python setup.py bdist_wheel --universal
python setup.py sdist
PyPi upload:
twine upload dist/*
"""
from __future__ import division, absolute_import, print_function
# numpy.distutils will figure out if setuptools is available when imported
# this allows us to combine setuptools use_pyscaffold=True and f2py extensions
import setuptools
from numpy.distutils.core import setup
from numpy.distutils.misc_util import Configuration
import sys
def setup_package_pyscaffold():
config = Configuration('wafo')
# -------------------------------------------------------------------------
# c_library
config.add_extension('c_library',
sources=['wafo/source/c_library/c_library.pyf',
'wafo/source/c_library/c_functions.c'])
# -------------------------------------------------------------------------
# mvn
config.add_extension('mvn',
sources=['wafo/source/mvn/mvn.pyf',
'wafo/source/mvn/mvndst.f'])
# -------------------------------------------------------------------------
# mvnprdmod
lib_mvnprdmod_src = ['wafo/source/mvnprd/mvnprd.f',
'wafo/source/mvnprd/mvnprodcorrprb.f']
config.add_library('_mvnprdmod', sources=lib_mvnprdmod_src)
config.add_extension('mvnprdmod',
sources=['wafo/source/mvnprd/mvnprd_interface.f'],
libraries=['_mvnprdmod'],
depends=(lib_mvnprdmod_src))
# -------------------------------------------------------------------------
# cov2mod
lib_cov2mod_src = ['wafo/source/mreg/dsvdc.f',
'wafo/source/mreg/mregmodule.f',
'wafo/source/mreg/intfcmod.f']
config.add_library('_cov2mod', sources=lib_cov2mod_src)
config.add_extension('cov2mod',
sources=['wafo/source/mreg/cov2mmpdfreg_intfc.f'],
libraries=['_cov2mod'],
include_dirs=['wafo/source/mreg/'],
depends=(lib_cov2mod_src))
# -------------------------------------------------------------------------
# rindmod
lib_rindmod_src = ['wafo/source/rind2007/intmodule.f',
'wafo/source/rind2007/jacobmod.f',
'wafo/source/rind2007/swapmod.f',
'wafo/source/rind2007/fimod.f',
'wafo/source/rind2007/rindmod.f',
'wafo/source/rind2007/rind71mod.f']
config.add_library('_rindmod', sources=lib_rindmod_src)
config.add_extension('rindmod',
sources=['wafo/source/rind2007/rind_interface.f'],
libraries=['_rindmod'],
include_dirs=['wafo/source/mreg/'],
depends=(lib_rindmod_src))
config.add_data_dir(('data', 'wafo/data'))
needs_sphinx = {'build_sphinx', 'upload_docs'}.intersection(sys.argv)
sphinx = ['sphinx'] if needs_sphinx else []
setup(setup_requires=['six', 'pyscaffold>=2.4rc1,<2.5a0'] + sphinx,
tests_require=['pytest_cov', 'pytest'],
use_pyscaffold=True,
**config.todict())
if __name__ == "__main__":
setup_package_pyscaffold()
setuptools.setup(
name='wafo',
version='0.11',
author='WAFO-group',
author_email=None,
description='Wave Analysis for Fatigue and Oceanography',
packages=setuptools.find_packages(),
)

@ -1,69 +0,0 @@
<map version="0.8.1">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1268907205249" ID="Freemind_Link_1834025809" MODIFIED="1268920224244" STYLE="fork" TEXT="WAFO Objects">
<font NAME="SansSerif" SIZE="11"/>
<node CREATED="1268919537155" ID="Freemind_Link_823244205" MODIFIED="1268920190865" POSITION="right" STYLE="bubble" TEXT="SpecData1D" VSHIFT="36">
<node CREATED="1268908695254" ID="Freemind_Link_834391422" MODIFIED="1268908707582" TEXT="bandwidth"/>
<node CREATED="1268908733082" ID="Freemind_Link_1433599166" MODIFIED="1268908736348" TEXT="characteristic"/>
<node CREATED="1268908690441" ID="Freemind_Link_1284342306" MODIFIED="1268908694941" TEXT="normalize"/>
<node CREATED="1268908669144" ID="Freemind_Link_1815459961" MODIFIED="1268908677316" TEXT="nyquist_freq"/>
<node CREATED="1268908664160" ID="Freemind_Link_703739784" MODIFIED="1268919800253" TEXT="moment" VSHIFT="4"/>
<node CREATED="1268908678394" ID="Freemind_Link_1387269779" MODIFIED="1268919203464" TEXT="sampling_period" VSHIFT="3"/>
<node CREATED="1268908643159" ID="Freemind_Link_895051601" MODIFIED="1268908655410" TEXT="stats_nl"/>
<node CREATED="1268907362986" ID="Freemind_Link_1959199999" MODIFIED="1268920763548" TEXT="sim">
<arrowlink DESTINATION="Freemind_Link_1110096845" ENDARROW="Default" ENDINCLINATION="-26;-470;" ID="Freemind_Arrow_Link_658989110" STARTARROW="None" STARTINCLINATION="134;20;"/>
</node>
<node CREATED="1268908639894" ID="Freemind_Link_881848843" MODIFIED="1268920768236" TEXT="sim_nl" VSHIFT="-116">
<arrowlink DESTINATION="Freemind_Link_1110096845" ENDARROW="Default" ENDINCLINATION="-12;-203;" ID="Freemind_Arrow_Link_194892354" STARTARROW="None" STARTINCLINATION="286;65;"/>
</node>
<node CREATED="1268908656097" ID="Freemind_Link_932055041" MODIFIED="1268920049331" TEXT="testgaussian" VSHIFT="-11"/>
<node CREATED="1268908524408" ID="Freemind_Link_451836141" MODIFIED="1268920637967" TEXT="tocovdata" VSHIFT="122">
<arrowlink DESTINATION="Freemind_Link_1298097150" ENDARROW="Default" ENDINCLINATION="22;-61;" ID="Freemind_Arrow_Link_459039584" STARTARROW="None" STARTINCLINATION="155;-17;"/>
</node>
<node CREATED="1268907881846" ID="Freemind_Link_961675105" MODIFIED="1268908523861" TEXT="tocov_matrix"/>
<node CREATED="1268908531877" ID="Freemind_Link_1361566099" MODIFIED="1268920224244" TEXT="to_linspec"/>
<node CREATED="1268908548674" ID="Freemind_Link_28901814" MODIFIED="1268920222025" TEXT="to_specnorm"/>
<node CREATED="1268908684613" ID="Freemind_Link_180569473" MODIFIED="1268917666022" TEXT="resample"/>
</node>
<node CREATED="1268918310233" HGAP="471" ID="Freemind_Link_1110096845" MODIFIED="1268920768236" POSITION="right" STYLE="bubble" TEXT="TimeSeries" VSHIFT="-65">
<node CREATED="1268918758255" ID="Freemind_Link_1306080198" MODIFIED="1268920381237" STYLE="fork" TEXT="tospecdata"/>
<node CREATED="1268918767833" ID="Freemind_Link_1037382917" MODIFIED="1268920384363" STYLE="fork" TEXT="tocovdata"/>
<node CREATED="1268918809021" ID="Freemind_Link_767625747" MODIFIED="1268918816990" STYLE="fork" TEXT="wave_periods"/>
<node CREATED="1268918817396" ID="Freemind_Link_294440483" MODIFIED="1268918823943" STYLE="fork" TEXT="reconstruct"/>
<node CREATED="1268918824365" ID="Freemind_Link_1893872699" MODIFIED="1268920714281" STYLE="fork" TEXT="plot_wave" VSHIFT="29"/>
<node CREATED="1268918835318" ID="Freemind_Link_1625232632" MODIFIED="1268918848897" STYLE="fork" TEXT="plot_sp_wave"/>
<node CREATED="1268918669644" ID="Freemind_Link_525365373" MODIFIED="1268918757817" STYLE="fork" TEXT="sampling_period"/>
<node CREATED="1268918800427" ID="Freemind_Link_540262488" MODIFIED="1268920657436" STYLE="fork" TEXT="through_crest" VSHIFT="11">
<arrowlink DESTINATION="Freemind_Link_1866699423" ENDARROW="Default" ENDINCLINATION="120;-87;" ID="Freemind_Arrow_Link_724369012" STARTARROW="None" STARTINCLINATION="298;0;"/>
</node>
<node CREATED="1268918781115" ID="Freemind_Link_191369931" MODIFIED="1268920652670" STYLE="fork" TEXT="turning_points">
<arrowlink DESTINATION="Freemind_Link_1866699423" ENDARROW="Default" ENDINCLINATION="354;-263;" ID="Freemind_Arrow_Link_301423490" STARTARROW="None" STARTINCLINATION="-57;21;"/>
</node>
</node>
<node CREATED="1268917687085" ID="Freemind_Link_1298097150" MODIFIED="1268920673171" POSITION="right" STYLE="bubble" TEXT="CovData1D" VSHIFT="-212">
<node CREATED="1268917901666" ID="Freemind_Link_1791940512" MODIFIED="1268919887910" STYLE="fork" TEXT="tospecdata">
<arrowlink DESTINATION="Freemind_Link_823244205" ENDARROW="Default" ENDINCLINATION="14;87;" ID="Freemind_Arrow_Link_728651707" STARTARROW="None" STARTINCLINATION="-21;-38;"/>
</node>
<node CREATED="1268918164841" ID="Freemind_Link_1718380955" MODIFIED="1268918173622" STYLE="fork" TEXT="sampling_period"/>
<node CREATED="1268918174044" ID="Freemind_Link_1888500587" MODIFIED="1268920740704" STYLE="fork" TEXT="sim">
<arrowlink DESTINATION="Freemind_Link_1110096845" ENDARROW="Default" ENDINCLINATION="-2;21;" ID="Freemind_Arrow_Link_174025984" STARTARROW="None" STARTINCLINATION="271;12;"/>
</node>
<node CREATED="1268918178013" ID="Freemind_Link_757742844" MODIFIED="1268920750954" STYLE="fork" TEXT="simcond">
<arrowlink DESTINATION="Freemind_Link_1110096845" ENDARROW="Default" ENDINCLINATION="-46;173;" ID="Freemind_Arrow_Link_1889053469" STARTARROW="None" STARTINCLINATION="171;0;"/>
</node>
</node>
<node CREATED="1268918904132" ID="Freemind_Link_1866699423" MODIFIED="1268920673171" POSITION="right" STYLE="bubble" TEXT="TurningPoints">
<node CREATED="1268918978226" ID="Freemind_Link_1033172969" MODIFIED="1268918989023" STYLE="fork" TEXT="cycle_pairs"/>
</node>
<node CREATED="1268918988977" ID="Freemind_Link_280025207" MODIFIED="1268920787861" POSITION="right" STYLE="bubble" TEXT="CyclePairs" VSHIFT="91">
<node CREATED="1268919011477" ID="Freemind_Link_867889153" MODIFIED="1268919019180" STYLE="fork" TEXT="amplitudes"/>
<node CREATED="1268919019586" ID="Freemind_Link_40128767" MODIFIED="1268919024414" STYLE="fork" TEXT="damage"/>
<node CREATED="1268919025024" ID="Freemind_Link_1194799087" MODIFIED="1268919033727" STYLE="fork" TEXT="level_crossings"/>
</node>
<node CREATED="1268919295668" ID="Freemind_Link_106637151" MODIFIED="1268919305606" POSITION="right" STYLE="bubble" TEXT="LevelCrossings">
<node CREATED="1268919349809" ID="Freemind_Link_1941466065" MODIFIED="1268920453960" STYLE="fork" TEXT="sim"/>
<node CREATED="1268919305574" ID="Freemind_Link_1378561112" MODIFIED="1268919349122" STYLE="fork" TEXT="trdata"/>
</node>
<node CREATED="1268920796033" ID="_" MODIFIED="1268920800424" POSITION="right" STYLE="bubble" TEXT="TrData"/>
</node>
</map>

@ -2,28 +2,28 @@ from __future__ import division, print_function, absolute_import
from .info import __doc__
from . import misc
from . import data
from . import demos
from . import kdetools
from . import objects
from . import spectrum
from . import transform
from . import definitions
from . import polynomial
from . import stats
from . import interpolate
from . import dctpack
from . import wave_theory
try:
from . import fig
except ImportError:
print('fig import only supported on Windows')
# from . import misc
# from . import data
# from . import demos
# from . import kdetools
# from . import objects
# from . import spectrum
# from . import transform
# from . import definitions
# from . import polynomial
# from . import stats
# from . import interpolate
# from . import dctpack
# from . import wave_theory
# try:
# from . import fig
# except ImportError:
# print('fig import only supported on Windows')
try:
from wafo.version import version as __version__
except ImportError:
__version__ = 'nobuilt'
# try:
# from wafo.version import version as __version__
# except ImportError:
# __version__ = 'nobuilt'
from numpy.testing import Tester
test = Tester().test
# from numpy.testing import Tester
# test = Tester().test

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 KiB

@ -1,97 +0,0 @@
"""
Module extending the bitoperator capabilites of numpy
"""
from numpy import (bitwise_and, bitwise_or,
bitwise_not, binary_repr, # @UnusedImport
bitwise_xor, where, arange) # @UnusedImport
__all__ = ['bitwise_and', 'bitwise_or', 'bitwise_not', 'binary_repr',
'bitwise_xor', 'getbit', 'setbit', 'getbits', 'setbits']
def getbit(i, bit):
"""
Get bit at specified position
Parameters
----------
i : array-like of uints, longs
value to
bit : array-like of ints or longs
bit position between 0 and the number of bits in the uint class.
Examples
--------
>>> import numpy as np
>>> binary_repr(13)
'1101'
>>> getbit(13,np.arange(3,-1,-1))
array([1, 1, 0, 1])
>>> getbit(5, np.r_[0:4])
array([1, 0, 1, 0])
"""
return bitwise_and(i, 1 << bit) >> bit
def getbits(i, numbits=8):
"""
Returns bits of i in a list
"""
return getbit(i, arange(0, numbits))
def setbit(i, bit, value=1):
"""
Set bit at specified position
Parameters
----------
i : array-like of uints, longs
value to
bit : array-like of ints or longs
bit position between 0 and the number of bits in the uint class.
value : array-like of 0 or 1
value to set the bit to.
Examples
--------
Set bit fifth bit in the five bit binary binary representation of 9 (01001)
yields 25 (11001)
>>> setbit(9,4)
array(25)
"""
val1 = 1 << bit
val0 = bitwise_not(val1)
return where((value == 0) & (i == i) & (bit == bit), bitwise_and(i, val0),
bitwise_or(i, val1))
def setbits(bitlist):
"""
Set bits of val to values in bitlist
Example
-------
>>> setbits([1,1])
3
>>> setbits([1,0])
1
"""
val = 0
for i, j in enumerate(bitlist):
val |= j << i
return val
if __name__ == '__main__':
from wafo.testing import test_docstrings
test_docstrings(__file__)
# t = set(np.arange(8),1,1)
# t=get(0x84,np.arange(0,8))
# t=getbyte(0x84)
# t=get(0x84,[0, 1, 2, 3, 4, 5, 6, 7])
# t=get(0x20, 6)
# bit = [0 for i in range(8)]
# bit[7]=1
# t = setbits(bit)
# print(hex(t))

@ -1,3 +0,0 @@
# TODO Fix doctests in fig.py
collect_ignore = ["fig.py", "MSO.py", "MSPPT.py", "powerpoint.py",
"win32_utils.py"]

@ -25,7 +25,7 @@ from numpy.random import randn
import scipy.interpolate as interpolate
from scipy.linalg import toeplitz, lstsq
from scipy import sparse
from pylab import stineman_interp
# from pylab import stineman_interp
from ..containers import PlotData
from ..misc import sub_dict_select, nextpow2 # , JITImport

@ -1,3 +0,0 @@
from __future__ import absolute_import
from .info import __doc__
from .info import *

@ -1,582 +0,0 @@
5.4829629629629641e+00
4.3614999999999986e+00
5.2602325581395339e+00
3.0619230769230770e+00
4.4896296296296301e+00
3.3681395348837206e+00
4.0259523809523818e+00
4.3966666666666665e+00
4.2999999999999998e+00
7.0564705882352934e+00
6.1440000000000001e+00
4.3543243243243239e+00
4.3595121951219520e+00
7.1674999999999995e+00
6.0100000000000007e+00
3.8176923076923064e+00
3.8862962962962957e+00
4.4436363636363652e+00
4.8211111111111098e+00
7.1261904761904749e+00
3.7118181818181823e+00
8.1500000000000004e+00
7.7725000000000000e+00
4.5788000000000011e+00
4.1022222222222222e+00
5.2209756097560973e+00
5.7300000000000004e+00
2.7129629629629628e+00
2.4211111111111108e+00
2.8095454545454532e+00
2.4837209302325594e+00
2.4050000000000002e+00
4.2750000000000004e+00
3.9422222222222221e+00
3.8742307692307696e+00
2.3256818181818173e+00
2.6061538461538465e+00
3.0470370370370370e+00
1.8579545454545447e+00
4.8434090909090912e+00
4.7172093023255792e+00
2.9300000000000002e+00
3.2725000000000000e+00
5.7482608695652173e+00
4.5774074074074083e+00
5.3236363636363633e+00
5.9372499999999988e+00
5.0633333333333335e+00
7.6900000000000004e+00
4.9976923076923079e+00
5.0788888888888879e+00
4.1337209302325579e+00
4.6752272727272706e+00
2.1450000000000000e+00
2.9566666666666670e+00
1.1678124999999998e+01
1.0795000000000000e+01
6.3430000000000009e+00
5.9580952380952388e+00
9.2199999999999989e+00
6.3524999999999991e+00
6.3756000000000004e+00
7.0014285714285718e+00
5.0088372093023246e+00
6.2643243243243232e+00
6.1133333333333333e+00
5.3249999999999993e+00
2.7474074074074073e+00
4.6804545454545430e+00
5.7633333333333336e+00
5.0625000000000000e+00
4.9824999999999999e+00
6.3411999999999997e+00
4.5371428571428583e+00
3.5171428571428587e+00
3.1532558139534879e+00
5.2366666666666664e+00
5.1399999999999988e+00
8.4735714285714288e+00
7.1446666666666658e+00
3.5134090909090903e+00
2.9665909090909079e+00
6.0766666666666671e+00
3.8666666666666667e+00
4.9534615384615384e+00
4.8718518518518508e+00
4.8771428571428563e+00
6.2160975609756104e+00
6.8499999999999996e+00
4.2533333333333330e+00
4.9648148148148143e+00
4.9369230769230761e+00
5.1770833333333330e+00
3.1988372093023254e+00
3.6213636363636370e+00
9.4099999999999984e+00
7.7975000000000003e+00
6.8578947368421055e+00
7.5875000000000004e+00
1.9634090909090893e+00
2.4779545454545455e+00
5.7725000000000000e+00
5.6566666666666663e+00
3.5634615384615382e+00
3.4437037037037039e+00
2.9709090909090894e+00
2.8075000000000006e+00
5.7266666666666666e+00
5.0633333333333335e+00
5.6592307692307688e+00
4.8769230769230765e+00
4.5544186046511639e+00
5.0542105263157877e+00
8.0066666666666677e+00
6.9049999999999994e+00
3.1661538461538474e+00
2.7900000000000000e+00
2.2986363636363647e+00
2.8874418604651164e+00
3.5874999999999999e+00
4.4849999999999994e+00
9.3166666666666682e+00
9.7884615384615401e+00
3.9845454545454548e+00
3.8721052631578958e+00
4.7133333333333338e+00
3.8250000000000002e+00
4.3996153846153847e+00
3.8052000000000006e+00
4.9980952380952370e+00
4.2854545454545452e+00
3.9000000000000004e+00
3.5349999999999997e+00
2.4480769230769228e+00
3.1014814814814819e+00
8.3771428571428572e+00
9.8775000000000013e+00
3.9299999999999997e+00
5.6400000000000006e+00
9.2333333333333343e+00
7.3440909090909097e+00
5.8252380952380962e+00
6.1797674418604664e+00
4.2533333333333330e+00
4.2750000000000004e+00
4.2941666666666665e+00
4.6457692307692309e+00
4.7833333333333332e+00
3.3774999999999995e+00
3.2266666666666675e+00
2.3244444444444445e+00
2.4297674418604669e+00
2.5704761904761906e+00
2.6066666666666669e+00
2.1533333333333333e+00
3.3025925925925925e+00
3.0223809523809528e+00
5.0890697674418597e+00
4.8595348837209293e+00
3.8475000000000001e+00
4.0325000000000006e+00
4.7977777777777764e+00
4.2389285714285716e+00
4.8243902439024371e+00
6.7746666666666640e+00
4.9933333333333332e+00
1.2701333333333332e+01
1.0377999999999998e+01
9.7267999999999990e+00
6.4125581395348812e+00
3.2033333333333331e+00
5.6233333333333340e+00
2.8969999999999989e+00
8.4913793103448274e+00
5.1333333333333329e+00
4.6433333333333335e+00
2.9820000000000007e+00
2.6970370370370373e+00
2.9765909090909086e+00
3.3188372093023251e+00
4.4299999999999997e+00
3.7174999999999998e+00
4.2815384615384611e+00
3.6144444444444441e+00
3.9388095238095255e+00
3.8513953488372095e+00
4.3999999999999995e+00
4.6066666666666665e+00
4.5448148148148153e+00
5.7560000000000002e+00
5.3117857142857128e+00
2.5165909090909095e+00
2.8383720930232559e+00
3.8250000000000002e+00
6.2425000000000006e+00
3.9725925925925933e+00
3.7232142857142856e+00
4.3255813953488396e+00
4.5230952380952374e+00
4.6066666666666665e+00
4.2233333333333336e+00
4.4750000000000014e+00
4.5025925925925936e+00
5.7267500000000009e+00
6.3217647058823534e+00
4.0433333333333339e+00
4.2074999999999996e+00
5.2319230769230769e+00
5.7133333333333338e+00
1.9861363636363627e+00
2.6293181818181823e+00
4.6733333333333329e+00
6.7050000000000001e+00
3.8875999999999999e+00
5.0888000000000000e+00
5.5153488372093014e+00
7.4194444444444452e+00
6.1099999999999994e+00
5.3824999999999994e+00
4.2187499999999991e+00
3.8128571428571418e+00
3.4400000000000004e+00
4.1067441860465115e+00
2.6999999999999997e+00
2.8600000000000003e+00
4.0196153846153839e+00
3.8457692307692311e+00
3.8817948717948707e+00
3.7552272727272711e+00
7.4275000000000002e+00
8.6899999999999995e+00
6.4753846153846162e+00
6.0141666666666653e+00
8.0438235294117675e+00
5.9988235294117649e+00
6.7933333333333339e+00
3.1400000000000001e+00
3.3200000000000003e+00
4.1522222222222203e+00
3.8577777777777786e+00
3.3722727272727266e+00
3.3793181818181810e+00
4.2266666666666666e+00
3.5549999999999997e+00
4.5107407407407401e+00
3.5775000000000001e+00
6.9528571428571420e+00
6.0760526315789498e+00
4.3299999999999992e+00
3.0000000000000000e+00
7.0819999999999981e+00
6.2977777777777781e+00
3.2575000000000003e+00
3.5443181818181810e+00
9.6750000000000007e+00
8.2336363636363643e+00
8.7376923076923081e+00
8.5203448275862055e+00
7.6451724137931034e+00
3.8666666666666667e+00
3.5866666666666673e+00
4.9269230769230763e+00
5.9090909090909101e+00
4.4325000000000001e+00
5.4964102564102548e+00
2.8775000000000004e+00
3.2966666666666669e+00
2.5385185185185191e+00
2.6122222222222224e+00
4.2142222222222214e+00
4.1902631578947371e+00
4.6266666666666660e+00
3.8533333333333335e+00
8.4165000000000010e+00
5.5291666666666659e+00
2.3225581395348835e+00
3.0686363636363638e+00
4.0800000000000001e+00
3.7133333333333329e+00
5.5911538461538459e+00
6.5222727272727266e+00
3.6168181818181817e+00
3.4525000000000015e+00
3.1800000000000002e+00
4.3366666666666669e+00
4.1024999999999991e+00
6.4061111111111115e+00
6.1661904761904767e+00
8.1230000000000011e+00
5.8008571428571418e+00
6.4733333333333336e+00
1.0175000000000001e+01
5.0976190476190473e+00
5.2099999999999991e+00
3.5631818181818171e+00
4.1541860465116276e+00
5.4874999999999998e+00
6.9100000000000001e+00
9.7192857142857143e+00
9.8164285714285722e+00
5.6602564102564097e+00
8.7630769230769214e+00
1.0220000000000001e+01
1.0695000000000000e+01
3.3466666666666676e+00
3.4067857142857143e+00
3.1056818181818184e+00
3.2893023255813940e+00
5.6650000000000009e+00
6.1125000000000007e+00
9.8085714285714314e+00
1.2693333333333333e+01
6.8272222222222219e+00
5.9281249999999996e+00
4.7619999999999996e+00
3.9049999999999998e+00
6.0947500000000012e+00
5.3353333333333337e+00
4.9464705882352931e+00
2.7939999999999992e+00
3.6475000000000000e+00
4.0997222222222245e+00
4.8644444444444437e+00
5.6488235294117644e+00
7.6616666666666688e+00
3.9233333333333325e+00
4.2925806451612898e+00
5.9369565217391322e+00
5.0370588235294118e+00
3.7346666666666666e+00
4.6871428571428577e+00
6.2183333333333337e+00
4.9388888888888873e+00
3.6206249999999986e+00
7.6308823529411747e+00
4.7541176470588242e+00
4.6737209302325571e+00
4.8757142857142863e+00
6.9187179487179495e+00
6.2716666666666656e+00
3.2473333333333332e+00
2.9200000000000004e+00
2.6910810810810815e+00
4.6559090909090921e+00
8.3445454545454538e+00
4.6804545454545439e+00
2.2156249999999997e+00
1.9752941176470586e+00
2.5693478260869576e+00
2.1659999999999995e+00
5.6924999999999999e+00
4.6219444444444466e+00
3.3962222222222200e+00
3.8658823529411754e+00
5.9802439024390246e+00
5.5507142857142862e+00
7.6572727272727281e+00
7.2237837837837819e+00
4.6305555555555564e+00
3.9100000000000006e+00
4.6493750000000000e+00
5.5844444444444434e+00
3.0119565217391302e+00
6.4043750000000008e+00
9.5586206896551715e+00
7.2057142857142855e+00
5.6258333333333317e+00
5.7640476190476182e+00
7.1963636363636363e+00
5.6874418604651167e+00
5.4273333333333342e+00
6.0615151515151524e+00
5.5800000000000018e+00
4.1017647058823528e+00
2.6497777777777776e+00
5.2453333333333330e+00
7.3470967741935489e+00
4.3131818181818193e+00
5.5653333333333324e+00
7.0499999999999980e+00
3.7619999999999991e+00
5.0675757575757592e+00
5.9769999999999985e+00
6.7249999999999988e+00
8.6042307692307691e+00
3.5806666666666662e+00
3.5815625000000004e+00
3.7788636363636381e+00
3.7358333333333325e+00
5.1269565217391317e+00
4.8678571428571429e+00
5.5264705882352940e+00
4.2017073170731711e+00
3.7105882352941166e+00
5.3206818181818178e+00
2.9713333333333343e+00
2.7563888888888886e+00
7.6529629629629641e+00
6.4521428571428556e+00
5.8050000000000006e+00
2.0128571428571429e+00
4.2888888888888896e+00
5.9328571428571450e+00
1.0609999999999999e+01
3.7197777777777770e+00
3.1337500000000009e+00
3.2837837837837829e+00
4.4520000000000000e+00
4.6988235294117651e+00
5.7946511627906983e+00
4.8130769230769230e+00
5.3478125000000007e+00
6.2370731707317066e+00
7.8106249999999990e+00
3.8891304347826114e+00
2.3959999999999999e+00
4.2005405405405414e+00
4.7605128205128180e+00
6.9815384615384621e+00
9.1547058823529408e+00
4.0542857142857134e+00
3.8008333333333320e+00
3.1255813953488385e+00
4.2582352941176467e+00
4.8453488372093014e+00
5.1150000000000002e+00
4.7213513513513510e+00
3.4827272727272724e+00
3.0505882352941178e+00
2.7824444444444429e+00
7.7399999999999993e+00
1.0409130434782606e+01
5.9644444444444451e+00
1.0795999999999999e+01
8.9992592592592597e+00
6.3976923076923091e+00
7.1279310344827573e+00
4.2302272727272721e+00
3.2905882352941180e+00
4.7038636363636357e+00
3.4220000000000002e+00
4.2258823529411762e+00
3.2204444444444449e+00
2.4581249999999999e+00
2.1877777777777769e+00
2.1423913043478255e+00
2.2755555555555547e+00
3.2992857142857148e+00
4.5726666666666667e+00
4.4771428571428586e+00
4.4768181818181816e+00
4.5383333333333340e+00
4.2769565217391312e+00
4.6015384615384614e+00
5.7247058823529393e+00
4.9804444444444425e+00
3.6694444444444434e+00
1.1215238095238094e+01
9.1850000000000005e+00
5.3722222222222227e+00
6.2425000000000042e+00
7.3538461538461544e+00
3.0506250000000006e+00
7.5833333333333321e+00
4.0663636363636355e+00
3.4388235294117653e+00
3.5664444444444445e+00
3.0406666666666671e+00
3.8337142857142852e+00
3.7924444444444458e+00
5.3774999999999986e+00
4.4091111111111108e+00
4.1324999999999994e+00
3.8061111111111114e+00
4.5399999999999991e+00
3.6055555555555543e+00
3.9333333333333367e+00
7.2324324324324314e+00
2.5419999999999998e+00
3.4575675675675668e+00
5.8765116279069751e+00
9.4742857142857133e+00
3.7115217391304345e+00
4.8933333333333326e+00
6.4018181818181805e+00
4.4633333333333329e+00
3.6568750000000003e+00
4.3422727272727268e+00
4.2013333333333325e+00
4.1880555555555556e+00
3.4113636363636362e+00
4.9605882352941180e+00
4.7213333333333320e+00
2.1199999999999992e+00
3.2251351351351345e+00
7.0423333333333336e+00
4.8461111111111101e+00
3.5000000000000000e+00
4.7093333333333343e+00
6.8564516129032258e+00
5.3060465116279092e+00
3.3566666666666656e+00
4.4884444444444425e+00
3.9066666666666667e+00
4.9237837837837830e+00
2.8633333333333337e+00
2.3141176470588238e+00
3.9447727272727278e+00
3.9740000000000006e+00
3.1935135135135138e+00
7.9008333333333338e+00
1.2878000000000000e+01
7.3702380952380944e+00
8.6866666666666656e+00
5.4328571428571442e+00
5.2213953488372109e+00
9.0155555555555562e+00
3.6631707317073179e+00
3.6888888888888900e+00
4.1529545454545467e+00
3.5973333333333337e+00
3.4672972972972973e+00
3.3593333333333320e+00
3.2805882352941182e+00
4.6777777777777771e+00
6.9690909090909088e+00
5.7182758620689640e+00
2.7732608695652186e+00
3.6272222222222235e+00
6.5997368421052620e+00
3.5273333333333339e+00
3.3930555555555548e+00
1.0433571428571428e+01
9.1080000000000005e+00
8.6382608695652188e+00
8.7341666666666669e+00
7.3107692307692300e+00
3.3476744186046501e+00
2.6300000000000003e+00
4.5486666666666657e+00
3.9621428571428572e+00
5.5491176470588242e+00
2.5150000000000010e+00
2.5094444444444446e+00
2.1204651162790711e+00
4.4307142857142860e+00
4.5968571428571421e+00
5.1136585365853655e+00
4.6394444444444449e+00
6.1210000000000004e+00
2.0293750000000004e+00
3.0340540540540539e+00
3.5041304347826112e+00
3.1037499999999993e+00
5.1755813953488401e+00
3.9831250000000002e+00
4.4294594594594594e+00
4.3844444444444450e+00
3.9411111111111108e+00
6.6910526315789474e+00
8.6833333333333318e+00
5.3197058823529408e+00
6.9751612903225810e+00
5.9539999999999997e+00
4.9557777777777785e+00
3.4481250000000006e+00
4.9451428571428577e+00
6.9590322580645161e+00
8.6592307692307688e+00
8.1816666666666666e+00
5.0956249999999992e+00
8.1888000000000005e+00
1.0237058823529411e+01
5.3599999999999994e+00
3.6475555555555559e+00
3.2793333333333341e+00
5.1406060606060597e+00
5.8326190476190503e+00
5.1949999999999985e+00
1.0530500000000000e+01
6.6633333333333340e+00
5.4306060606060624e+00

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,485 +0,0 @@
"""
Data package in WAFO Toolbox.
Contents
--------
atlantic - Significant wave-height data recorded in the Atlantic Ocean
gfaks89 - Surface elevation measured at Gullfaks C 24.12.1989
gfaksr89 - Reconstructed surface elevation measured at Gullfaks C 24.12.1989.
japansea - coastline map of The Japan Sea
northsea - coastline map of The Nortsea
sea - Surface elevation dataset used in WAT version 1.1.
sfa89 - Wind measurements at Statfjord A 24.12.1989
sn - Fatigue experiment, constant-amplitude loading.
yura87 - Surface elevation measured off the coast of Yura
This module gives gives detailed information and easy access to all datasets
included in WAFO
"""
import numpy as np
import os
__path2data = os.path.dirname(os.path.realpath(__file__))
__all__ = ['atlantic', 'gfaks89', 'gfaksr89', 'japansea', 'northsea', 'sea',
'sfa89', 'sn', 'yura87']
_NANS = set(['nan', 'NaN', '-1.#IND00+00', '1.#IND00+00', '-1.#INF00+00'])
def _tofloat(x):
return np.nan if x in _NANS else float(x or 0)
_MYCONVERTER = {}
for i in range(2):
_MYCONVERTER[i] = _tofloat
def _load(file): # @ReservedAssignment
""" local load function
"""
return np.loadtxt(os.path.join(__path2data, file))
def _loadnan(file): # @ReservedAssignment
""" local load function accepting nan's
"""
return np.loadtxt(os.path.join(__path2data, file), converters=_MYCONVERTER)
def atlantic():
"""
Return Significant wave-height data recorded in the Atlantic Ocean
Data summary
------------
Size : 582 X 1
Sampling Rate : ~ 14 times a month
Device :
Source :
Format : ascii
Description
------------
atlantic.dat contains average significant wave-height data recorded
approximately 14 times a month in December-February during 7 years and
at 2 locations in the Atlantic Ocean
Example
--------
>>> import pylab
>>> import wafo
>>> Hs = wafo.data.atlantic()
>>> np.allclose(Hs[:3], [ 5.48296296, 4.3615 , 5.26023256])
True
h = pylab.plot(Hs)
Acknowledgement:
---------------
This dataset were made available by Dr. David Carter
and Dr. David Cotton, Satellite Observing Systems, UK.
"""
return _load('atlantic.dat')
def gfaks89():
"""
Return Surface elevation measured at Gullfaks C 24.12.1989
Data summary
------------
Size : 39000 X 2
Sampling Rate : 2.5 Hz
Device : EMI laser
Source : STATOIL
Format : ascii, c1: time c2: surface elevation
Description
------------
The wave data was measured 24th December 1989 at the Gullfaks C platform
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
is missing and contains NaNs. The water depth of 218 m is
regarded as deep water for the most important wave components.
There are two EMI laser sensors named 219 and 220. This data set is
obtained from sensor 219, which is located in the Northwest
corner approximately two platform leg diameters away from
the closest leg.
Thus the wave elevation is not expected to be significantly
affected by diffraction effects for incoming waves in the western sector.
The wind direction for this period is from the south.
Some difficulties in calibration of the instruments have been reported
resulting in several consecutive measured values being equal or almost
equal in the observed data set.
This dataset is for non-commercial use only.
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.gfaks89()
>>> np.allclose(x[:3, 1], [-0.19667949, -0.46667949, -0.38667949])
True
h = pylab.plot(x[:,0],x[:,1])
Acknowledgement:
---------------
This dataset were prepared and made available by Dr. S. Haver,
STATOIL, Norway
See also
--------
gfaksr89, northsea
"""
return _loadnan('gfaks89.dat')
def gfaksr89():
"""
Return a reconstruction of surface elevation measured at Gullfaks C
24.12.1989.
Data summary
------------
Size : 39000 X 2
Sampling Rate : 2.5 Hz
Device : EMI laser
Source : STATOIL
Format : ascii, c1: time c2: surface elevation
Description
-----------
This is a reconstructed version of the data in the GFAKS89.DAT file.
The following calls were made to reconstruct the data:
inds = findoutliers(gfaks89,.02,2,1.23);
gfaksr89 = reconstruct(gfaks89,inds,6);
The wave data was measured 24th December 1989 at the Gullfaks C platform
in the North Sea from 17.00 to 21.20. The period from 20.00 to 20.20
is missing in the original data. The water depth of 218 m is
regarded as deep water for the most important wave components.
There are two EMI laser sensors named 219 and 220. This data set is
obtained from sensor 219, which is located in the Northwest
corner approximately two platform leg diameters away from
the closest leg.
Thus the wave elevation is not expected to be significantly
affected by diffraction effects for incoming waves in the western sector.
The wind direction for this period is from the south.
Some difficulties in calibration of the instruments have been reported
resulting in several consecutive measured values being equal or almost
equal in the observed data set.
Hm0 = 6.8m, Tm02 = 8s, Tp = 10.5
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.gfaksr89()
h = pylab.plot(x[:,0],x[:,1])
See also
--------
gfaks89
"""
return _loadnan('gfaksr89.dat')
def japansea():
"""
Return coastline map of The Japan Sea
Data summary
------------
Size : 692 X 2
Sampling Rate :
Device :
Source : http://crusty.er.usgs.gov/coast/getcoast.html
Format : ascii, c1: longitude c2: latitude
Description
-----------
JAPANSEA.DAT contains data for plotting a map of The Japan Sea.
The data is obtained from USGS coastline extractor.
Example:
-------
#the map is seen by
>>> import pylab
>>> import wafo
>>> map1 = wafo.data.japansea()
>>> np.allclose(map1[1:4, 0], [ 141.960057, 142.058624, 142.103214])
True
h = pylab.plot(map1[:,0],map1[:,1])
lon_loc = [131,132,132,135,139.5,139]
lat_loc = [46, 43, 40, 35, 38.3, 35.7]
loc = ['China','Vladivostok','Japan Sea', 'Japan', 'Yura','Tokyo']
algn = 'right'
for lon, lat, name in zip(lon_loc,lat_loc,loc):
pylab.text(lon,lat,name,horizontalalignment=algn)
# If you have the m_map toolbox (see http://www.ocgy.ubc.ca/~rich/):
m_proj('lambert','long',[130 148],'lat',[30 48]);
m_line(map(:,1),map(:,2));
m_grid('box','fancy','tickdir','out');
m_text(131,46,'China');
m_text(132,43,'Vladivostok');
m_text(132,40,'Japan Sea');
m_text(135,35,'Japan');
m_text(139.5,38.3,'Yura');
m_text(139,35.7,'Tokyo');
"""
return _loadnan('japansea.dat')
def northsea():
"""
NORTHSEA coastline map of The Nortsea
Data summary
-------------
Size : 60646 X 2
Sampling Rate :
Device :
Source : http://crusty.er.usgs.gov/coast/getcoast.html
Format : ascii, c1: longitude c2: latitude
Description
-----------
NORTHSEA.DAT contains data for plotting a map of The Northsea.
The data is obtained from USGS coastline extractor.
Example
-------
# the map is seen by
>>> import pylab
>>> import wafo
>>> map1 = wafo.data.northsea()
>>> np.allclose(map1[1:4, 0], [ 1.261996, 1.264064, 1.268171])
True
h = pylab.plot(map1[:,0],map1[:,1])
lon_pltfrm = [1.8, 2.3, 2., 1.9, 2.6]
lat_pltfrm = [61.2, 61.2, 59.9, 58.4, 57.7]
pltfrm = ['Statfjord A', 'Gullfaks C', 'Frigg', 'Sleipner', 'Draupner']
h = pylab.scatter(lon_pltfrm,lat_pltfrm);
algn = 'right'
for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
pylab.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
lon_city = [10.8, 10.8, 5.52, 5.2]
lat_city = [59.85, 63.4, 58.9, 60.3]
city = ['Oslo','Trondheim','Stavanger', 'Bergen']
h = pylab.scatter(lon_city,lat_city);
algn = 'right'
for lon, lat, name in zip(lon_city,lat_city,city):
pylab.text(lon,lat,name,horizontalalignment=algn)
# If you have the mpl_toolkits.basemap installed
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# setup Lambert Conformal basemap.
m = Basemap(width=1200000,height=900000,projection='lcc',
resolution='f',lat_1=56.,lat_2=64,lat_0=58,lon_0=5.)
m.drawcoastlines()
h = m.scatter(lon_pltfrm,lat_pltfrm);
algn = 'right'
for lon, lat, name in zip(lon_pltfrm,lat_pltfrm,pltfrm):
m.text(lon,lat,name,horizontalalignment=algn); algn = 'left'
m.scatter(lon_city,lat_city)
algn = 'right'
for lon, lat, name in zip(lon_city,lat_city,city):
m.text(lon,lat,name,horizontalalignment=algn)
"""
return _loadnan('northsea.dat')
def sea():
"""
Return Surface elevation dataset used in WAT version 1.1.
Data summary
------------
Size : 9524 X 2
Sampling Rate : 4.0 Hz
Device : unknown
Source : unknown
Format : ascii, c1: time c2: surface elevation
Description
-----------
The wave data was used in one of WAFO predecessors, i.e. the Wave
Analysis Toolbox version 1.1 (WAT)
Hm0 = 1.9m, Tm02 = 4.0s, Tp2 = 11.5s Tp1=5.6s
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.sea()
>>> np.allclose(x[:3,1],[-1.2004945 , -1.0904945 , -0.79049454])
True
h = pylab.plot(x[:,0],x[:,1])
"""
return _load('sea.dat')
def sfa89():
"""
Return Wind measurements at Statfjord A 24.12.1989
Data summary
------------
Size : 144 X 3
Sampling Rate : 1/600 Hz
Device :
Source : DNMI (The Norwegian Meteorological Institute)
Format : ascii, c1: time (hours)
c2: velocity (m/s)
c3: direction (degrees)
Description
-----------
The registration of wind speeds at the Gullfaks field
started up on Statfjord A in 1978 and continued until 1990.
The dataregistration was transferred to Gullfaks C in Nov 1989.
Due to some difficulties of the windregistration on Gullfaks C in
the beginning, they continued to use the registered data from
Statfjord A.
The windspeed is measured in (meter/second), 110 m above mean water
level (MWL) and the wind direction is given in degrees for the data.
The data are a mean value of every 10 minutes.
Wind directions are defined in the meteorological convention, i.e.,
0 degrees = wind approaching from North, 90 degrees = wind from East, etc.
This dataset is for non-commercial use only.
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.sfa89()
h = pylab.plot(x[:,0],x[:,1])
Acknowledgement
----------------
These data are made available by Knut A. Iden, DNMI.
See also
--------
northsea
"""
return _load('sfa89.dat')
def sn():
"""
Return SN Fatigue experiment, constant-amplitude loading.
Data summary
------------
Size : 40 X 2
Source : unknown
Format : ascii, c1: Amplitude MPa c2: Number of cycles
Description
-----------
A fatigue experiment with constant amplitudes at five levels:
10,15,20,25 and 30 MPa. For each level is related 8 observations of
the number of cycles to failure.
The origin of the data is unknown.
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.sn()
h = pylab.plot(x[:,0],x[:,1])
See also
--------
The same data appear in the directory wdemos/itmkurs/
as SN.mat.
"""
return _load('sn.dat')
def yura87():
"""
Return Surface elevation measured off the coast of Yura.
Data summary
-----------
Size : 85547 X 4
Sampling Rate : 1 Hz
Device : ultrasonic wave gauges
Source : SRI, Ministry of Transport, Japan
Format : ascii, c1: time (sec) c2-4: surface elevation (m)
Description
-----------
The wave data was measured at the Poseidon platform
in the Japan Sea from 24th November 1987 08.12 hours to 25th November
1987 07.57 hours. Poseidon was located 3 km off the coast of Yura
in the Yamagata prefecture, in the Japan Sea during the measurements.
The most important wave components are to some extent influenced by the
water depth of 42 m. The data are measured with three ultrasonic wave
gauges located at the sea floor and the relative coordinates of the
gauges are as follows (x-axis points to the East, y-axis points to
the North):
X (m) Y (m)
c2: -4.93, 25.02
c3: 5.80, 92.12
c4: 0.00, 0.00
This dataset is for non-commercial use only.
Hm0 = 5.1m, Tm02 = 7.7s, Tp = 12.8s
Example
-------
>>> import pylab
>>> import wafo
>>> x = wafo.data.yura87()
h = pylab.plot(x[:,0],x[:,1])
Acknowledgement:
-----------------
This dataset were prepared and made available by Dr. Sc. H. Tomita,
Ship Research Institute, Ministry of Transport, Japan.
See also
--------
japansea
"""
return _load('yura87.dat')
if __name__ == '__main__':
import doctest
doctest.testmod()

@ -1,692 +0,0 @@
nan nan
141.960057 40.022926
142.058624 39.818752
142.103214 39.640392
142.157191 39.469073
142.136070 39.332957
142.070358 39.229696
142.046890 39.074805
141.927201 38.955116
141.805166 38.948076
141.727720 38.765023
141.638541 38.542073
141.638541 38.368408
141.629153 38.316777
141.396817 38.333205
141.143358 38.194742
141.054179 37.934243
141.087034 37.671397
141.143358 37.453142
141.143358 37.143360
141.164480 36.957960
140.976733 36.826537
140.854698 36.603588
140.812455 36.533182
140.756131 36.258603
140.744396 35.944127
140.887553 35.791583
140.922756 35.683628
140.767865 35.603836
140.589505 35.359765
140.479204 35.162631
140.237480 35.007740
nan nan
139.984022 35.233036
140.016877 35.369152
140.148300 35.495881
140.192890 35.622610
nan nan
139.972288 39.161638
140.070855 39.323569
140.138913 39.530091
140.148300 39.750693
140.016877 39.844567
nan nan
140.237480 35.007740
139.993409 34.862236
139.951166 35.007740
139.984022 35.233036
nan nan
140.192890 35.622610
139.951166 35.622610
139.894842 35.451291
139.805662 35.305788
139.784541 35.153243
139.653118 35.233036
139.409047 35.261198
139.298746 35.115694
139.254156 34.918560
139.209566 34.726119
139.089878 34.618165
138.956108 34.636940
138.911518 34.871623
138.946721 35.035902
138.791830 35.052329
138.625204 34.925600
138.460926 34.763669
138.348278 34.580616
138.315422 34.554800
138.195733 34.571228
137.996252 34.608778
137.731060 34.618165
137.477602 34.618165
137.256999 34.554800
137.212409 34.554800
137.278121 34.636940
137.388422 34.709692
137.266387 34.726119
137.167820 34.744894
137.113842 34.798871
137.057518 34.709692
136.935483 34.817646
136.926096 35.017127
136.836916 34.981924
136.714880 34.754281
136.628048 34.618165
136.771204 34.536026
136.968339 34.416337
136.968339 34.179307
136.836916 34.270833
136.714880 34.216856
136.583458 34.198081
136.449688 34.134717
136.372243 34.040844
136.351121 33.977479
136.229086 33.813201
136.064807 33.555049
135.853592 33.454135
135.701048 33.498725
135.579012 33.555049
135.478098 33.702899
135.290352 33.803813
135.236374 33.977479
135.248108 34.134717
135.248108 34.261446
135.334941 34.334198
135.501567 34.564188
135.522688 34.636940
135.478098 34.662755
135.325554 34.643980
135.147195 34.608778
134.926592 34.681530
134.684868 34.726119
134.464266 34.716732
134.264785 34.580616
134.142749 34.526638
133.978471 34.435112
133.955002 34.425725
133.901025 34.463274
133.835314 34.489089
133.680423 34.444499
133.579509 34.435112
133.403496 34.371747
133.281461 34.362360
133.161772 34.308383
133.016268 34.280221
132.851990 34.233284
132.664243 34.198081
132.530473 34.298995
132.420172 34.270833
132.300484 34.015028
132.244160 33.885952
132.154980 33.867178
131.924990 33.932889
131.758365 34.005641
131.570618 33.949317
131.427461 33.949317
131.338281 33.914114
131.162269 33.968092
130.986256 33.996254
130.974522 34.207469
130.997990 34.317770
131.195124 34.362360
131.460317 34.416337
131.636329 34.571228
131.814689 34.681530
132.122124 34.827033
132.321605 35.045289
132.563329 35.179059
132.718220 35.387927
132.917701 35.486494
133.138304 35.549859
133.304929 35.521697
133.459820 35.477107
133.800111 35.505269
134.077038 35.495881
134.309374 35.540471
134.583954 35.594448
134.795169 35.631998
134.959448 35.639038
135.137807 35.693015
135.325554 35.702403
135.313820 35.559246
135.412387 35.531084
135.733903 35.477107
135.820736 35.495881
135.909916 35.568633
136.031951 35.631998
136.142253 35.693015
136.142253 35.944127
136.151640 36.176464
136.440301 36.382985
136.682025 36.631750
136.836916 36.932144
136.848650 37.143360
136.893240 37.312332
137.233531 37.469570
137.388422 37.453142
137.355566 37.312332
137.212409 37.248967
137.057518 37.126932
137.036397 37.082342
137.113842 36.915717
137.113842 36.737357
137.224144 36.727970
137.433012 36.756132
137.609025 36.906329
137.853095 37.011937
138.151144 37.091729
138.470313 37.284170
138.681528 37.453142
138.836419 37.654970
139.012432 37.847410
139.233035 37.960058
139.244769 37.969446
139.254156 37.976486
139.355070 37.976486
139.507614 38.152499
139.531083 38.307390
139.575672 38.438813
139.695361 38.628906
139.850252 38.835428
139.927698 38.997359
139.972288 39.161638
nan nan
140.016877 39.844567
139.805662 39.912625
139.906576 39.980683
nan nan
138.604083 38.272187
138.580614 38.098521
138.625204 38.056278
138.514903 37.812208
138.360012 37.802820
138.327156 37.950671
138.449192 38.204129
138.604083 38.272187
nan nan
134.276519 33.268735
134.065304 33.379036
133.800111 33.454135
133.570121 33.397811
133.391762 33.296897
133.293195 33.111497
133.105448 32.879160
133.084326 32.712535
132.905967 32.693760
132.751076 32.804061
132.685365 32.879160
132.553942 33.083335
132.575063 33.167821
132.509352 33.278122
132.387316 33.360261
132.223038 33.360261
132.488230 33.536274
132.697099 33.756876
132.896580 33.977479
133.105448 33.949317
133.239218 33.895340
133.436352 33.932889
133.624099 34.005641
133.689810 34.134717
133.823580 34.226244
133.933881 34.317770
134.065304 34.334198
134.264785 34.289608
134.452531 34.198081
134.619157 34.188694
134.661400 33.996254
134.717724 33.822588
134.762314 33.803813
134.771701 33.794426
134.762314 33.766264
134.652012 33.665350
134.551098 33.618413
134.452531 33.517499
134.363352 33.369649
134.276519 33.268735
nan nan
135.060362 34.571228
135.027506 34.526638
134.872615 34.371747
134.762314 34.207469
134.872615 34.179307
134.982916 34.226244
135.004038 34.390522
135.060362 34.571228
nan nan
130.864220 33.876565
130.920544 33.885952
130.831365 33.895340
130.676474 33.848403
130.521583 33.721674
130.423015 33.564436
130.279859 33.564436
130.178945 33.470563
130.035788 33.416585
nan nan
130.000000 32.676758
130.146089 32.712535
130.324448 32.628049
130.411281 32.759472
130.289246 32.813449
130.235269 32.897935
130.235269 33.083335
130.333836 33.149046
130.444137 32.944872
130.577907 32.766512
130.577907 32.599887
130.622496 32.581112
130.631884 32.581112
130.622496 32.386325
130.521583 32.179803
130.401894 32.095317
130.300980 31.935732
130.289246 31.710436
130.345570 31.464019
130.289246 31.323208
130.401894 31.229335
130.655352 31.123727
130.709329 31.341983
130.631884 31.520343
130.688208 31.663500
130.852486 31.625950
130.775041 31.569626
130.753919 31.445244
130.810243 31.248110
130.810243 31.011079
130.941666 31.048629
131.096557 31.161277
131.108291 31.304434
131.251448 31.435857
131.361750 31.388920
131.483785 31.625950
131.549496 31.879408
131.615208 32.114092
131.725509 32.386325
131.835810 32.552950
131.967233 32.712535
132.023557 32.794674
132.035291 32.841611
132.023557 32.998849
131.978967 33.073947
131.924990 33.174861
131.680919 33.221798
131.648063 33.306284
131.746630 33.517499
131.692653 33.627801
131.537762 33.583211
131.239714 33.573823
131.051967 33.766264
131.040233 33.857790
130.962788 33.857790
130.864220 33.876565
nan nan
130.146089 32.477851
130.092112 32.358163
130.080378 32.217353
130.113233 32.142254
130.247003 32.421527
130.146089 32.477851
nan nan
131.117679 30.630892
131.084823 30.764662
131.030846 30.630892
130.962788 30.410290
131.030846 30.344578
131.117679 30.630892
nan nan
130.545051 30.353966
130.512195 30.410290
130.455871 30.325804
130.512195 30.210809
130.676474 30.192034
130.676474 30.325804
130.545051 30.353966
nan nan
130.897076 37.539975
130.843099 37.495385
130.843099 37.478957
130.885342 37.453142
130.974522 37.504772
130.897076 37.539975
nan nan
130.035788 33.416585
130.000000 33.445983
nan nan
142.678694 48.000000
142.654720 47.880130
142.666454 47.650140
142.809611 47.448313
142.952768 47.335665
143.107659 47.194854
143.140515 47.028229
143.206226 46.915581
143.307140 46.840482
143.462031 46.772424
143.516009 46.802933
143.572333 46.755996
143.626310 46.582330
143.670900 46.415705
143.649778 46.225612
143.548864 46.070720
143.494887 46.270201
143.417442 46.537741
143.173371 46.605799
142.943381 46.687938
142.699310 46.697325
142.523297 46.558862
142.434118 46.361728
142.356672 46.148166
142.258105 45.955725
142.025768 46.049599
141.969444 46.354687
141.960057 46.657429
142.025768 46.983639
142.070358 47.194854
142.091480 47.441272
142.124335 47.671262
142.157191 47.894211
142.248875 48.000000
nan nan
148.000000 44.948933
147.909284 44.948933
147.789595 44.885569
147.679294 44.754146
147.566646 44.697822
147.435223 44.620376
147.313188 44.524156
147.214621 44.446711
147.071464 44.446711
147.125441 44.540584
147.235742 44.650885
147.280332 44.768227
147.381246 44.801083
147.590114 45.002910
147.733271 45.113212
147.864694 45.160148
147.953874 45.291571
148.000000 45.306694
nan nan
146.937694 43.843574
147.015140 43.820106
146.928307 43.756741
146.761682 43.691030
146.663115 43.730926
146.761682 43.796637
146.937694 43.843574
nan nan
146.210175 44.446711
146.231297 44.486607
146.287621 44.446711
146.365066 44.399774
146.419044 44.303554
146.320477 44.249576
146.120996 44.097032
145.912127 43.939794
145.724380 43.796637
145.614079 43.667561
145.536634 43.796637
145.703259 43.946835
145.900393 44.113460
146.067018 44.280085
146.144464 44.430283
146.210175 44.446711
nan nan
145.083695 44.066523
145.149406 44.113460
145.370008 44.256617
145.447454 44.209680
145.348887 44.003159
145.182262 43.780209
145.250320 43.620625
145.426332 43.540832
145.426332 43.339004
145.646935 43.331964
145.912127 43.404716
145.813560 43.249825
145.492044 43.146564
145.226851 43.001060
145.050839 42.977592
144.952272 43.017488
144.841970 42.904840
144.508720 42.935349
144.234140 42.911880
143.957214 42.799232
143.692021 42.538734
143.516009 42.285275
143.450297 42.048245
143.328262 41.923863
143.051335 42.081101
142.842467 42.196096
142.478708 42.294663
142.180659 42.440166
141.960057 42.529346
141.650275 42.555161
141.417938 42.473022
141.253660 42.367415
141.054179 42.383842
140.845310 42.505878
140.556650 42.489450
140.404105 42.311091
140.502672 42.153853
140.702153 42.097529
140.922756 42.015389
141.110503 41.900394
141.241925 41.808868
141.176214 41.710301
140.955612 41.726729
140.788986 41.719688
140.624708 41.635202
140.523794 41.520207
140.270336 41.388784
140.138913 41.421640
140.082589 41.562450
140.160034 41.801827
140.216358 41.982534
140.028612 42.120997
nan nan
139.927698 42.522306
140.094323 42.660769
140.326660 42.749949
140.514407 42.904840
140.568384 43.057384
140.469817 43.162992
140.514407 43.282680
140.744396 43.242784
140.964999 43.179420
141.152746 43.179420
141.363961 43.186460
141.495384 43.378901
141.462528 43.557260
141.462528 43.716845
141.596297 43.810718
141.727720 44.043055
141.739454 44.303554
141.805166 44.547624
141.870877 44.721290
141.805166 44.862100
141.727720 45.035766
141.683130 45.160148
141.694865 45.284531
141.793432 45.354936
141.903733 45.432381
141.992913 45.462890
142.124335 45.376057
142.136070 45.361976
142.180659 45.284531
142.347285 45.190657
142.490442 45.042807
142.610130 44.918424
142.765021 44.768227
142.931647 44.643845
143.140515 44.493647
143.339996 44.383346
143.516009 44.280085
143.736611 44.193252
143.936092 44.129888
144.144960 44.082951
144.332707 44.059483
144.443009 43.970303
144.654224 43.906938
144.863092 43.939794
145.083695 44.066523
nan nan
141.241925 45.230553
141.131624 45.167189
141.241925 45.096784
141.340492 45.089743
141.363961 45.230553
141.241925 45.230553
nan nan
141.209070 41.372356
141.230191 41.379397
141.363961 41.372356
141.485996 41.379397
141.528239 41.280830
141.518852 41.137673
141.495384 40.947579
141.518852 40.722283
141.605685 40.501681
141.793432 40.325668
141.903733 40.130881
141.960057 40.022926
nan nan
139.906576 39.980683
140.082589 40.182511
140.070855 40.435969
140.061467 40.611982
140.148300 40.729324
140.282070 40.787995
140.314926 40.787995
140.336047 40.863093
140.347781 41.022678
140.413493 41.130632
140.547262 41.179916
140.657563 41.071962
140.744396 40.879521
140.821842 40.797382
140.943877 40.931151
141.075300 40.888908
141.197336 40.895949
141.319371 41.088389
141.331105 41.245627
141.185601 41.156448
140.943877 41.104817
140.878166 41.264402
140.943877 41.428681
141.042444 41.454496
141.209070 41.372356
nan nan
132.729954 44.838632
132.786278 44.909037
132.828521 45.113212
132.741689 45.244634
132.521086 45.284531
132.178448 45.237594
132.089268 45.120252
132.199570 44.941893
132.199570 44.777614
132.300484 44.667313
132.476496 44.596908
132.697099 44.681394
132.729954 44.838632
nan nan
139.676457 48.000000
139.620262 47.962270
139.420781 47.814419
139.265890 47.619632
139.122733 47.441272
138.934986 47.291075
138.747240 47.140877
138.592349 46.960171
138.538371 46.817014
138.460926 46.643348
138.404602 46.521313
138.261445 46.324179
138.139409 46.162247
138.261445 46.392237
138.172265 46.256120
138.085432 46.110617
137.885951 45.979194
137.787384 45.817262
137.587903 45.655331
137.379035 45.509827
137.212409 45.361976
137.012928 45.230553
136.869772 45.113212
136.804060 45.035766
136.682025 44.901997
136.538868 44.808123
136.395711 44.643845
136.297144 44.500688
136.097663 44.413855
135.921650 44.289473
135.776146 44.146316
135.755025 44.033668
135.632989 43.899898
135.513301 43.763781
135.346676 43.597156
135.093217 43.404716
134.872615 43.282680
134.628544 43.162992
134.330496 43.008101
134.065304 42.846169
133.877557 42.782804
133.746134 42.782804
133.546653 42.740561
133.326051 42.677197
133.105448 42.700665
132.995147 42.749949
132.929435 42.740561
132.762810 42.829741
132.563329 42.855556
132.410785 42.846169
132.377929 42.895452
132.366195 43.033916
132.399051 43.137177
132.399051 43.242784
132.288749 43.209928
132.068147 43.090240
132.002435 43.146564
132.089268 43.282680
131.934377 43.299108
131.913256 43.418797
131.847544 43.292068
131.781833 43.106668
131.648063 42.984632
131.558884 42.928308
131.504906 42.822701
131.382871 42.740561
131.284304 42.611485
131.073089 42.611485
130.908810 42.620873
130.753919 42.595058
130.810243 42.529346
130.843099 42.423739
130.622496 42.562202
nan nan
140.028612 42.120997
139.883108 42.212523
139.894842 42.334559
139.927698 42.522306
nan nan
130.699942 42.374455
130.732798 42.278235
130.610762 42.301703
130.476993 42.268848
130.324448 42.130384
130.103846 41.956718
nan nan
130.103846 41.956718
130.000000 41.866852

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,16 +0,0 @@
%SEA Surface elevation dataset used in WAT version 1.1.
%
% CALL: xn = load('sea.dat');
%
% Size : 9524 X 2
% Sampling Rate : 4.0 Hz
% Device : unknown
% Source : unknown
% Format : ascii, c1: time c2: surface elevation
% Description :
% The wave data was used in one of WAFO predecessors, i.e. the Wave
% Analysis Toolbox version 1.1 (WAT)
%
% Hm0 = 1.9m, Tm02 = 4.0s, Tp2 = 11.5s Tp1=5.6s
%
% See also

@ -1,144 +0,0 @@
0.0000000e+00 1.2400000e+01 2.0700000e+02
1.6666667e-01 1.1800000e+01 2.0480000e+02
3.3333333e-01 1.1300000e+01 1.9940000e+02
5.0000000e-01 1.1800000e+01 1.9560000e+02
6.6666667e-01 1.3000000e+01 1.9500000e+02
8.3333333e-01 1.3400000e+01 1.9550000e+02
1.0000000e+00 1.2000000e+01 1.9250000e+02
1.1666667e+00 1.3300000e+01 1.9250000e+02
1.3333333e+00 1.4900000e+01 1.9450000e+02
1.5000000e+00 1.4400000e+01 1.9790000e+02
1.6666667e+00 1.3600000e+01 1.9800000e+02
1.8333333e+00 1.2400000e+01 1.8510000e+02
2.0000000e+00 1.5100000e+01 2.0260000e+02
2.1666667e+00 1.5000000e+01 2.0240000e+02
2.3333333e+00 1.4400000e+01 2.0540000e+02
2.5000000e+00 1.4600000e+01 2.0430000e+02
2.6666667e+00 1.2800000e+01 2.0370000e+02
2.8333333e+00 1.2600000e+01 2.0620000e+02
3.0000000e+00 1.5500000e+01 2.1350000e+02
3.1666667e+00 1.6700000e+01 2.1370000e+02
3.3333333e+00 1.7100000e+01 2.1490000e+02
3.5000000e+00 1.6500000e+01 2.1430000e+02
3.6666667e+00 1.6800000e+01 2.1440000e+02
3.8333333e+00 1.5100000e+01 2.1060000e+02
4.0000000e+00 1.5600000e+01 2.1050000e+02
4.1666667e+00 1.4700000e+01 2.0960000e+02
4.3333333e+00 1.3900000e+01 2.0860000e+02
4.5000000e+00 1.4200000e+01 2.0660000e+02
4.6666667e+00 1.4100000e+01 2.0500000e+02
4.8333333e+00 1.4800000e+01 2.0500000e+02
5.0000000e+00 1.4600000e+01 2.0050000e+02
5.1666667e+00 1.5100000e+01 1.9520000e+02
5.3333333e+00 1.5000000e+01 1.9360000e+02
5.5000000e+00 1.5600000e+01 1.9170000e+02
5.6666667e+00 1.6900000e+01 1.8940000e+02
5.8333333e+00 1.5800000e+01 1.8690000e+02
6.0000000e+00 1.6500000e+01 1.8230000e+02
6.1666667e+00 1.8100000e+01 1.8330000e+02
6.3333333e+00 1.8400000e+01 1.8080000e+02
6.5000000e+00 1.7900000e+01 1.7960000e+02
6.6666667e+00 1.8900000e+01 1.7910000e+02
6.8333333e+00 2.0000000e+01 1.7830000e+02
7.0000000e+00 2.0000000e+01 1.7830000e+02
7.1666667e+00 2.1400000e+01 1.7780000e+02
7.3333333e+00 2.0800000e+01 1.7530000e+02
7.5000000e+00 2.1800000e+01 1.7380000e+02
7.6666667e+00 2.1800000e+01 1.7130000e+02
7.8333333e+00 2.2600000e+01 1.7220000e+02
8.0000000e+00 2.2700000e+01 1.7260000e+02
8.1666667e+00 2.4100000e+01 1.7300000e+02
8.3333333e+00 2.3500000e+01 1.7180000e+02
8.5000000e+00 2.4100000e+01 1.7080000e+02
8.6666667e+00 2.4400000e+01 1.6950000e+02
8.8333333e+00 2.4900000e+01 1.7010000e+02
9.0000000e+00 2.6500000e+01 1.7290000e+02
9.1666667e+00 2.6500000e+01 1.7210000e+02
9.3333333e+00 2.6300000e+01 1.7200000e+02
9.5000000e+00 2.7300000e+01 1.7250000e+02
9.6666667e+00 2.7300000e+01 1.7520000e+02
9.8333333e+00 2.7800000e+01 1.7220000e+02
1.0000000e+01 2.7200000e+01 1.7460000e+02
1.0166667e+01 2.7900000e+01 1.7790000e+02
1.0333333e+01 2.8400000e+01 1.7830000e+02
1.0500000e+01 2.8300000e+01 1.7590000e+02
1.0666667e+01 2.7300000e+01 1.7460000e+02
1.0833333e+01 2.7600000e+01 1.7310000e+02
1.1000000e+01 2.9300000e+01 1.7520000e+02
1.1166667e+01 2.9600000e+01 1.7580000e+02
1.1333333e+01 2.8700000e+01 1.7430000e+02
1.1500000e+01 2.8200000e+01 1.7300000e+02
1.1666667e+01 2.8100000e+01 1.7000000e+02
1.1833333e+01 2.9100000e+01 1.6820000e+02
1.2000000e+01 2.8800000e+01 1.7040000e+02
1.2166667e+01 2.9600000e+01 1.7150000e+02
1.2333333e+01 2.9900000e+01 1.7160000e+02
1.2500000e+01 2.9500000e+01 1.7210000e+02
1.2666667e+01 3.0100000e+01 1.7560000e+02
1.2833333e+01 3.0900000e+01 1.7520000e+02
1.3000000e+01 3.0900000e+01 1.7550000e+02
1.3166667e+01 3.0000000e+01 1.7590000e+02
1.3333333e+01 3.0500000e+01 1.7490000e+02
1.3500000e+01 3.0500000e+01 1.7340000e+02
1.3666667e+01 3.0100000e+01 1.7190000e+02
1.3833333e+01 3.1500000e+01 1.7180000e+02
1.4000000e+01 3.0700000e+01 1.7190000e+02
1.4166667e+01 2.9200000e+01 1.6820000e+02
1.4333333e+01 3.1200000e+01 1.6770000e+02
1.4500000e+01 3.1900000e+01 1.6970000e+02
1.4666667e+01 3.1300000e+01 1.7140000e+02
1.4833333e+01 3.1300000e+01 1.7500000e+02
1.5000000e+01 3.1500000e+01 1.7470000e+02
1.5166667e+01 3.1800000e+01 1.7430000e+02
1.5333333e+01 3.1500000e+01 1.7460000e+02
1.5500000e+01 3.2800000e+01 1.7610000e+02
1.5666667e+01 3.2700000e+01 1.7710000e+02
1.5833333e+01 3.1000000e+01 1.7970000e+02
1.6000000e+01 3.0100000e+01 1.8010000e+02
1.6166667e+01 3.0000000e+01 1.7880000e+02
1.6333333e+01 2.9200000e+01 1.7930000e+02
1.6500000e+01 2.9900000e+01 1.7890000e+02
1.6666667e+01 3.0300000e+01 1.7940000e+02
1.6833333e+01 3.0700000e+01 1.7930000e+02
1.7000000e+01 3.0600000e+01 1.8020000e+02
1.7166667e+01 3.0300000e+01 1.7970000e+02
1.7333333e+01 3.1100000e+01 1.7920000e+02
1.7500000e+01 2.8900000e+01 1.8200000e+02
1.7666667e+01 3.0300000e+01 1.8100000e+02
1.7833333e+01 2.9900000e+01 1.7940000e+02
1.8000000e+01 3.0800000e+01 1.7920000e+02
1.8166667e+01 2.9500000e+01 1.7950000e+02
1.8333333e+01 3.0600000e+01 1.7900000e+02
1.8500000e+01 3.0800000e+01 1.7880000e+02
1.8666667e+01 3.0900000e+01 1.8070000e+02
1.8833333e+01 3.0700000e+01 1.8040000e+02
1.9000000e+01 3.0700000e+01 1.7990000e+02
1.9166667e+01 2.9400000e+01 1.8020000e+02
1.9333333e+01 2.9100000e+01 1.7990000e+02
1.9500000e+01 3.0600000e+01 1.8040000e+02
1.9666667e+01 3.0100000e+01 1.8110000e+02
1.9833333e+01 3.0000000e+01 1.8130000e+02
2.0000000e+01 2.9300000e+01 1.8300000e+02
2.0166667e+01 3.0500000e+01 1.8390000e+02
2.0333333e+01 3.0800000e+01 1.8470000e+02
2.0500000e+01 2.9600000e+01 1.8530000e+02
2.0666667e+01 2.8800000e+01 1.8600000e+02
2.0833333e+01 2.9100000e+01 1.8640000e+02
2.1000000e+01 2.9800000e+01 1.8570000e+02
2.1166667e+01 2.8700000e+01 1.8750000e+02
2.1333333e+01 2.8700000e+01 1.8640000e+02
2.1500000e+01 2.9300000e+01 1.8610000e+02
2.1666667e+01 2.8500000e+01 1.8800000e+02
2.1833333e+01 2.7200000e+01 1.9140000e+02
2.2000000e+01 2.8100000e+01 1.9130000e+02
2.2166667e+01 2.7000000e+01 1.9330000e+02
2.2333333e+01 2.6300000e+01 1.9900000e+02
2.2500000e+01 2.6100000e+01 2.0270000e+02
2.2666667e+01 2.4000000e+01 2.1240000e+02
2.2833333e+01 2.4000000e+01 2.1840000e+02
2.3000000e+01 2.1600000e+01 2.1300000e+02
2.3166667e+01 1.8800000e+01 2.0440000e+02
2.3333333e+01 1.7700000e+01 1.9810000e+02
2.3500000e+01 1.8500000e+01 1.9840000e+02
2.3666667e+01 1.9600000e+01 1.9660000e+02
2.3833333e+01 1.9200000e+01 1.9410000e+02

@ -1,40 +0,0 @@
1.0000000000000000e+01 1.2075320000000000e+06
1.0000000000000000e+01 1.0013290000000000e+06
1.0000000000000000e+01 1.1642510000000000e+06
1.0000000000000000e+01 1.0521420000000000e+06
1.0000000000000000e+01 1.3143320000000000e+06
1.0000000000000000e+01 9.2781600000000000e+05
1.0000000000000000e+01 8.5991500000000000e+05
1.0000000000000000e+01 9.8150100000000000e+05
1.5000000000000000e+01 1.9180900000000000e+05
1.5000000000000000e+01 3.5513600000000000e+05
1.5000000000000000e+01 2.5113800000000000e+05
1.5000000000000000e+01 3.2085900000000000e+05
1.5000000000000000e+01 4.2688000000000000e+05
1.5000000000000000e+01 1.9037600000000000e+05
1.5000000000000000e+01 3.3071300000000000e+05
1.5000000000000000e+01 3.1301500000000000e+05
2.0000000000000000e+01 6.8162000000000000e+04
2.0000000000000000e+01 1.3884800000000000e+05
2.0000000000000000e+01 1.0781100000000000e+05
2.0000000000000000e+01 1.4487700000000000e+05
2.0000000000000000e+01 1.5860000000000000e+05
2.0000000000000000e+01 8.9558000000000000e+04
2.0000000000000000e+01 1.7458000000000000e+05
2.0000000000000000e+01 1.1393600000000000e+05
2.5000000000000000e+01 5.3675000000000000e+04
2.5000000000000000e+01 6.3114000000000000e+04
2.5000000000000000e+01 6.6566000000000000e+04
2.5000000000000000e+01 4.6152000000000000e+04
2.5000000000000000e+01 5.5601000000000000e+04
2.5000000000000000e+01 6.3908000000000000e+04
2.5000000000000000e+01 4.6279000000000000e+04
2.5000000000000000e+01 4.3226000000000000e+04
3.0000000000000000e+01 1.9547000000000000e+04
3.0000000000000000e+01 2.4162000000000000e+04
3.0000000000000000e+01 2.7696000000000000e+04
3.0000000000000000e+01 3.5947000000000000e+04
3.0000000000000000e+01 4.9134000000000000e+04
3.0000000000000000e+01 2.5054000000000000e+04
3.0000000000000000e+01 3.0502000000000000e+04
3.0000000000000000e+01 4.1359000000000000e+04

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

@ -1,211 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by Microsoft Visio 11.0, SVG Export, v1.0 wafo.svg Page-3 -->
<svg
xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="8.26772in"
height="11.6929in"
viewBox="0 0 595.276 841.89"
xml:space="preserve"
color-interpolation-filters="sRGB"
class="st4"
id="svg2269"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docname="wafoLogoNewWithBorder.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
sodipodi:docbase="K:\pab\matlab\wafosvn\wafo\data"
inkscape:export-filename="K:\pab\seamocs\wafo\wafoOrig3.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"><metadata
id="metadata2325"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs2323">
<title
id="title2275">Page-3</title>
<v:pageProperties
v:shadowOffsetY="-8.50394"
v:shadowOffsetX="8.50394"
v:drawingUnits="24"
v:pageScale="0.0393701"
v:drawingScale="0.0393701" />
<title
id="title2278">Sheet.1</title>
<title
id="title2306">Sheet.7</title>
</defs><sodipodi:namedview
inkscape:window-height="878"
inkscape:window-width="1280"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
guidetolerance="10.0"
gridtolerance="10.0"
objecttolerance="10.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base"
inkscape:zoom="1.7424566"
inkscape:cx="353.93418"
inkscape:cy="530.60308"
inkscape:window-x="0"
inkscape:window-y="88"
inkscape:current-layer="svg2269" />
<v:documentProperties
v:langID="1033"
v:viewMarkup="false" />
<style
type="text/css"
id="style2271">
.st1 {fill:#99ccff;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72}
.st2 {fill:#99ccff}
.st3 {stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72}
.st4 {fill:none;fill-rule:evenodd;font-size:12;overflow:visible;stroke-linecap:square;stroke-miterlimit:3}
</style>
<g
id="g2184"
v:mID="6"
v:groupContext="shape"
transform="translate(353.50185,-422.77482)"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1">
<title
id="title2186">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2188"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><path
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2308"
class="st2"
d="M 215.52095,416.85104 L 215.85095,416.76104 C 220.23289,418.1841 224.80414,418.93924 229.41095,419.00104 L 199.43095,419.00104 L 23.50095,419.00104 C 63.19839,418.99975 98.6955,395.07432 112.46095,359.04104 C 112.84246,357.9133 113.24586,356.79309 113.67095,355.68104 C 121.18932,335.97437 135.26527,319.45825 153.53095,308.91104 C 167.48696,300.8565 183.31742,296.6178 199.43095,296.62104 C 220.89105,296.62261 240.78205,307.86584 251.85095,326.25104 C 252.04387,326.5693 252.23387,326.88931 252.42095,327.21104 C 254.07818,330.08102 255.49952,333.08089 256.67095,336.18104 C 248.94376,330.47985 239.6229,327.34608 230.02095,327.22104 L 229.72095,327.21104 C 207.02353,327.05002 187.61763,343.50509 184.06629,365.92354 C 180.51495,388.34199 193.88502,409.98916 215.52095,416.85104 L 215.52095,416.85104 z M 229.41095,419.00104 C 229.51428,419.00139 229.61762,419.00139 229.72095,419.00104 L 229.41095,419.00104 L 229.41095,419.00104 z M 229.72095,419.00104 L 230.02095,419.00104 L 229.72095,419.00104 L 229.72095,419.00104 z " /><path
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2310"
class="st3"
d="M 215.52095,416.85104 L 215.85095,416.76104 C 220.23289,418.1841 224.80414,418.93924 229.41095,419.00104 L 199.43095,419.00104 L 23.50095,419.00104 C 63.19839,418.99975 98.6955,395.07432 112.46095,359.04104 C 112.84246,357.9133 113.24586,356.79309 113.67095,355.68104 C 121.18932,335.97437 135.26527,319.45825 153.53095,308.91104 C 167.48696,300.8565 183.31742,296.6178 199.43095,296.62104 C 220.89105,296.62261 240.78205,307.86584 251.85095,326.25104 C 252.04387,326.5693 252.23387,326.88931 252.42095,327.21104 C 254.07818,330.08102 255.49952,333.08089 256.67095,336.18104 C 248.94376,330.47985 239.6229,327.34608 230.02095,327.22104 L 229.72095,327.21104 C 207.02353,327.05002 187.61763,343.50509 184.06629,365.92354 C 180.51495,388.34199 193.88502,409.98916 215.52095,416.85104 M 229.41095,419.00104 C 229.51428,419.00139 229.61762,419.00139 229.72095,419.00104 L 229.41095,419.00104 M 229.72095,419.00104 L 230.02095,419.00104 L 229.72095,419.00104" /><g
style="stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="shape2-2"
v:mID="2"
v:groupContext="shape"
transform="translate(203.0194,-484.1574)">
<title
id="title2281">Sheet.2</title>
<path
d="M 5.46,834.97 C 3.3155278,837.00103 1.4764469,839.33188 -1.1925672e-015,841.89 L 8.57,841.89 L 28.44,841.89 C 29.731238,836.8916 31.649812,832.07668 34.15,827.56 C 23.94872,824.92546 13.109603,827.72497 5.46,834.97 L 5.46,834.97 z "
class="st1"
id="path2283"
style="fill:#99ccff;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
style="stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="shape3-4"
v:mID="3"
v:groupContext="shape"
transform="translate(76.5354,-422.965)">
<title
id="title2286">Sheet.3</title>
<path
d="M 61.19,796 C 61.189242,787.5946 64.646473,779.55907 70.75,773.78 C 70.155747,772.70486 69.518568,771.65401 68.84,770.63 C 66.677258,767.36928 64.106406,764.39851 61.19,761.79 C 51.454477,770.49674 45.889798,782.93907 45.89,796 C 45.891817,806.49692 49.491912,816.67602 56.09,824.84 C 55.25174,825.13694 54.400932,825.39718 53.54,825.62 C 48.525469,826.91402 43.264531,826.91402 38.25,825.62 C 33.231033,824.32414 28.623577,821.77438 24.86,818.21 C 18.758996,812.43332 15.301988,804.40192 15.3,796 C 15.298262,790.78823 16.184266,785.61424 17.92,780.7 C 18.763907,778.31145 19.804127,775.99688 21.03,773.78 C 22.693324,770.7727 24.689169,767.96175 26.98,765.4 C 28.118655,764.13034 29.327196,762.92514 30.6,761.79 C 28.24732,759.68515 25.683747,757.82865 22.95,756.25 C 21.104007,755.18451 19.186031,754.24891 17.21,753.45 C 13.469155,757.31762 10.254769,761.66175 7.65,766.37 C 5.1498118,770.88668 3.2312383,775.7016 1.94,780.7 C 0.65066517,785.69777 -0.0011772613,790.83859 -2.3665698e-015,796 C 0.0026435879,809.05744 5.5670747,821.49558 15.3,830.2 C 17.65268,832.30485 20.216253,834.16135 22.95,835.74 C 27.681348,838.47278 32.862669,840.33873 38.25,841.25 C 40.774359,841.67605 43.329941,841.89013 45.89,841.89 C 53.94722,841.8901 61.862477,839.76901 68.84,835.74 C 73.571348,838.47278 78.752669,840.33873 84.14,841.25 C 86.667652,841.6766 89.226601,841.89068 91.79,841.89 C 97.688644,841.88968 103.53192,840.75226 109,838.54 C 110.97603,837.74109 112.89401,836.80549 114.74,835.74 C 117.47027,834.16077 120.03047,832.30429 122.38,830.2 C 121.11062,829.06458 119.90542,827.85938 118.77,826.59 C 116.47917,824.02825 114.48332,821.2173 112.82,818.21 C 111.59413,815.99312 110.55391,813.67855 109.71,811.29 C 107.97538,806.37892 107.0894,801.20841 107.09,796 C 107.08826,790.78823 107.97427,785.61424 109.71,780.7 C 110.55391,778.31145 111.59413,775.99688 112.82,773.78 C 114.48332,770.7727 116.47917,767.96175 118.77,765.4 C 119.90542,764.13062 121.11062,762.92542 122.38,761.79 C 118.43448,758.25899 113.9077,755.43736 109,753.45 C 105.25915,757.31762 102.04477,761.66175 99.44,766.37 C 96.939812,770.88668 95.021238,775.7016 93.73,780.7 C 92.440665,785.69777 91.788823,790.83859 91.79,796 C 91.789666,801.15806 92.441502,806.29547 93.73,811.29 C 94.430192,814.00083 95.315606,816.66042 96.38,819.25 C 97.276438,821.43051 98.298142,823.55739 99.44,825.62 C 94.422301,826.91574 89.157699,826.91574 84.14,825.62 C 83.279068,825.39718 82.42826,825.13694 81.59,824.84 C 77.552511,823.41294 73.859549,821.15424 70.75,818.21 C 70.083968,817.57897 69.446657,816.9183 68.84,816.23 C 67.4955,814.70535 66.30629,813.05051 65.29,811.29 C 62.605686,806.64125 61.191691,801.36809 61.19,796 z "
class="st1"
id="path2288"
style="fill:#99ccff;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
style="stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="shape4-6"
v:mID="4"
v:groupContext="shape"
transform="translate(198.9204,-422.965)">
<title
id="title2291">Sheet.4</title>
<path
d="M 47.81,838.54 C 44.069155,834.67238 40.854769,830.32825 38.25,825.62 C 33.233333,816.5536 30.601077,806.36178 30.6,796 L 0,796 C 0.0019883187,804.40192 3.4589958,812.43332 9.56,818.21 C 7.0683158,822.71453 3.8365461,826.76777 -3.5667036e-014,830.2 C 3.9485244,833.73199 8.4787648,836.55366 13.39,838.54 C 18.858079,840.75226 24.701356,841.88968 30.6,841.89 C 36.498644,841.88968 42.341921,840.75226 47.81,838.54 L 47.81,838.54 z "
class="st1"
id="path2293"
style="fill:#99ccff;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
id="shape6-10"
v:mID="6"
v:groupContext="shape"
transform="translate(291.16752,-422.77482)"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1">
<title
id="title2301">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2303"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
style="stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="shape8-15"
v:mID="8"
v:groupContext="shape"
transform="translate(321.3044,-438.2631)">
<title
id="title2313">Sheet.8</title>
<path
d="M 0.66,804.97 C 0.22124193,807.04805 4.9337977e-005,809.16614 -8.4213233e-016,811.29 C -0.00173203,823.19594 6.9033391,834.02169 17.7,839.04 C 19.389124,839.82517 21.146421,840.45445 22.95,840.92 C 32.112714,843.28407 41.853704,841.27543 49.333795,835.47954 C 56.813885,829.68364 61.191238,820.75278 61.19,811.29 C 61.188145,801.82898 56.809491,792.901 49.329842,787.1074 C 41.850193,781.3138 32.111014,779.30637 22.95,781.67 C 11.698204,784.57362 3.0624758,793.60065 0.66,804.97 L 0.66,804.97 z "
class="st1"
id="path2315"
style="fill:#99ccff;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
style="stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="shape9-17"
v:mID="9"
v:groupContext="shape"
transform="translate(244.8144,-434.6517)">
<title
id="title2318">Sheet.9</title>
<path
d="M 27.18,783.49 C 30.37046,781.1256 33.986249,779.39749 37.83,778.4 C 47.926884,775.79129 58.657172,778.50496 66.3,785.6 C 66.369401,785.473 66.439402,785.34634 66.51,785.22 C 68.139028,782.30777 69.755833,780.06867 71.975351,777.57698 L 75.762541,773.51888 C 76.9704,772.83669 74.666372,773.66976 76.150703,773.26302 C 74.017571,771.68987 75.329915,772.78466 75.088378,772.5107 C 71.389442,769.29521 68.011435,767.3416 63.49,765.45 C 57.914597,763.11726 51.933717,761.90749 45.89,761.89 C 41.970674,761.87571 38.065628,762.363 34.27,763.34 C 29.730068,764.51346 25.396538,766.37502 21.42,768.86 C 19.249037,770.21628 17.195223,771.75162 15.28,773.45 C 14.00412,774.58169 12.792244,775.78356 11.65,777.05 C 9.3432484,779.60319 7.3306275,782.40744 5.65,785.41 C 4.4101058,787.62889 3.3564901,789.94684 2.5,792.34 C 0.88804139,797.29563 0.044924941,802.46899 3.7470027e-016,807.68 C 0.00072628219,815.45325 1.9758087,823.09895 5.74,829.9 C 8.2316842,834.40453 11.463454,838.45777 15.3,841.89 C 16.569383,840.75458 17.77458,839.54938 18.91,838.28 C 21.091288,835.84112 23.005505,833.17597 24.62,830.33 C 24.700768,830.1871 24.78077,830.04376 24.86,829.9 C 18.756473,824.12093 15.299242,816.0854 15.3,807.68 L 61.19,807.68 C 61.191474,802.46766 62.080862,797.29365 63.82,792.38 L 19.4,792.38 C 20.593932,790.15426 22.125421,788.1269 23.94,786.37 C 24.243724,786.06684 24.553793,785.77011 24.87,785.48 C 25.606291,784.77851 26.377257,784.11435 27.18,783.49 L 27.18,783.49 z "
class="st1"
id="path2320"
style="fill:#99ccff;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
sodipodi:nodetypes="cccsccccsccssssccccssccccccccc" />
</g><g
id="g2190"
v:mID="6"
v:groupContext="shape"
transform="translate(229.31375,-422.77483)"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1">
<title
id="title2192">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2194"
style="fill:#195fdd;fill-opacity:1;stroke:#000000;stroke-width:1.48000216;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g><g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="W"
style="opacity:0.57471266" /><g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="WAVE"
sodipodi:insensitive="true" /></svg>

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

@ -1,243 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by Microsoft Visio 11.0, SVG Export, v1.0 wafo.svg Page-3 -->
<svg
xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="8.26772in"
height="11.6929in"
viewBox="0 0 595.276 841.89"
xml:space="preserve"
color-interpolation-filters="sRGB"
class="st4"
id="svg2269"
sodipodi:version="0.32"
inkscape:version="0.45.1"
sodipodi:docname="wafoLogoNewWithoutBorder.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
sodipodi:docbase="L:\wafosvn\wafo\data"
inkscape:export-filename="K:\pab\seamocs\wafo\wafoOrig3.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"><metadata
id="metadata2325"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs2323">
<title
id="title2275">Page-3</title>
<v:pageProperties
v:shadowOffsetY="-8.50394"
v:shadowOffsetX="8.50394"
v:drawingUnits="24"
v:pageScale="0.0393701"
v:drawingScale="0.0393701" />
<title
id="title2278">Sheet.1</title>
</defs><sodipodi:namedview
inkscape:window-height="878"
inkscape:window-width="1280"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
guidetolerance="10.0"
gridtolerance="10.0"
objecttolerance="10.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base"
inkscape:zoom="1.7424566"
inkscape:cx="353.93418"
inkscape:cy="530.60308"
inkscape:window-x="22"
inkscape:window-y="0"
inkscape:current-layer="svg2269" />
<v:documentProperties
v:langID="1033"
v:viewMarkup="false" />
<style
type="text/css"
id="style2271">
.st1 {fill:#99ccff;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72}
.st2 {fill:#99ccff}
.st3 {stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72}
.st4 {fill:none;fill-rule:evenodd;font-size:12;overflow:visible;stroke-linecap:square;stroke-miterlimit:3}
</style>
<g
id="shape7-12"
v:mID="7"
v:groupContext="shape"
transform="matrix(-1,0,0,1,256.67095,-422.88896)"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2306">Sheet.7</title>
<path
d="M 41.15,839.74 L 40.82,839.65 C 36.438057,841.07306 31.866812,841.8282 27.26,841.89 L 57.24,841.89 L 233.17,841.89 C 193.47256,841.88871 157.97545,817.96328 144.21,781.93 C 143.82849,780.80226 143.42509,779.68205 143,778.57 C 135.48163,758.86333 121.40568,742.34721 103.14,731.8 C 89.183986,723.74546 73.353531,719.50676 57.24,719.51 C 35.779898,719.51157 15.888896,730.7548 4.82,749.14 C 4.6270847,749.45826 4.4370768,749.77827 4.25,750.1 C 2.5927697,752.96998 1.1714283,755.96985 1.5743344e-014,759.07 C 7.7271908,753.36881 17.04805,750.23504 26.65,750.11 L 26.95,750.1 C 49.647419,749.93898 69.05332,766.39405 72.604659,788.8125 C 76.155997,811.23095 62.785926,832.87812 41.15,839.74 L 41.15,839.74 z M 27.26,841.89 C 27.156667,841.89035 27.053333,841.89035 26.95,841.89 L 27.26,841.89 L 27.26,841.89 z M 26.95,841.89 L 26.65,841.89 L 26.95,841.89 L 26.95,841.89 z "
class="st2"
id="path2308"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-opacity:1" />
<path
d="M 41.15,839.74 L 40.82,839.65 C 36.438057,841.07306 31.866812,841.8282 27.26,841.89 L 57.24,841.89 L 233.17,841.89 C 193.47256,841.88871 157.97545,817.96328 144.21,781.93 C 143.82849,780.80226 143.42509,779.68205 143,778.57 C 135.48163,758.86333 121.40568,742.34721 103.14,731.8 C 89.183986,723.74546 73.353531,719.50676 57.24,719.51 C 35.779898,719.51157 15.888896,730.7548 4.82,749.14 C 4.6270847,749.45826 4.4370768,749.77827 4.25,750.1 C 2.5927697,752.96998 1.1714283,755.96985 1.5743344e-014,759.07 C 7.7271908,753.36881 17.04805,750.23504 26.65,750.11 L 26.95,750.1 C 49.647419,749.93898 69.05332,766.39405 72.604659,788.8125 C 76.155997,811.23095 62.785926,832.87812 41.15,839.74 M 27.26,841.89 C 27.156667,841.89035 27.053333,841.89035 26.95,841.89 L 27.26,841.89 M 26.95,841.89 L 26.65,841.89 L 26.95,841.89"
class="st3"
id="path2310"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
style="stroke:none;stroke-opacity:1"
id="shape2-2"
v:mID="2"
v:groupContext="shape"
transform="translate(203.0194,-484.1574)"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2281">Sheet.2</title>
<path
d="M 5.46,834.97 C 3.3155278,837.00103 1.4764469,839.33188 -1.1925672e-015,841.89 L 8.57,841.89 L 28.44,841.89 C 29.731238,836.8916 31.649812,832.07668 34.15,827.56 C 23.94872,824.92546 13.109603,827.72497 5.46,834.97 L 5.46,834.97 z "
class="st1"
id="path2283"
style="fill:#99ccff;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
style="stroke:none;stroke-opacity:1"
id="shape3-4"
v:mID="3"
v:groupContext="shape"
transform="translate(76.5354,-422.965)"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2286">Sheet.3</title>
<path
d="M 61.19,796 C 61.189242,787.5946 64.646473,779.55907 70.75,773.78 C 70.155747,772.70486 69.518568,771.65401 68.84,770.63 C 66.677258,767.36928 64.106406,764.39851 61.19,761.79 C 51.454477,770.49674 45.889798,782.93907 45.89,796 C 45.891817,806.49692 49.491912,816.67602 56.09,824.84 C 55.25174,825.13694 54.400932,825.39718 53.54,825.62 C 48.525469,826.91402 43.264531,826.91402 38.25,825.62 C 33.231033,824.32414 28.623577,821.77438 24.86,818.21 C 18.758996,812.43332 15.301988,804.40192 15.3,796 C 15.298262,790.78823 16.184266,785.61424 17.92,780.7 C 18.763907,778.31145 19.804127,775.99688 21.03,773.78 C 22.693324,770.7727 24.689169,767.96175 26.98,765.4 C 28.118655,764.13034 29.327196,762.92514 30.6,761.79 C 28.24732,759.68515 25.683747,757.82865 22.95,756.25 C 21.104007,755.18451 19.186031,754.24891 17.21,753.45 C 13.469155,757.31762 10.254769,761.66175 7.65,766.37 C 5.1498118,770.88668 3.2312383,775.7016 1.94,780.7 C 0.65066517,785.69777 -0.0011772613,790.83859 -2.3665698e-015,796 C 0.0026435879,809.05744 5.5670747,821.49558 15.3,830.2 C 17.65268,832.30485 20.216253,834.16135 22.95,835.74 C 27.681348,838.47278 32.862669,840.33873 38.25,841.25 C 40.774359,841.67605 43.329941,841.89013 45.89,841.89 C 53.94722,841.8901 61.862477,839.76901 68.84,835.74 C 73.571348,838.47278 78.752669,840.33873 84.14,841.25 C 86.667652,841.6766 89.226601,841.89068 91.79,841.89 C 97.688644,841.88968 103.53192,840.75226 109,838.54 C 110.97603,837.74109 112.89401,836.80549 114.74,835.74 C 117.47027,834.16077 120.03047,832.30429 122.38,830.2 C 121.11062,829.06458 119.90542,827.85938 118.77,826.59 C 116.47917,824.02825 114.48332,821.2173 112.82,818.21 C 111.59413,815.99312 110.55391,813.67855 109.71,811.29 C 107.97538,806.37892 107.0894,801.20841 107.09,796 C 107.08826,790.78823 107.97427,785.61424 109.71,780.7 C 110.55391,778.31145 111.59413,775.99688 112.82,773.78 C 114.48332,770.7727 116.47917,767.96175 118.77,765.4 C 119.90542,764.13062 121.11062,762.92542 122.38,761.79 C 118.43448,758.25899 113.9077,755.43736 109,753.45 C 105.25915,757.31762 102.04477,761.66175 99.44,766.37 C 96.939812,770.88668 95.021238,775.7016 93.73,780.7 C 92.440665,785.69777 91.788823,790.83859 91.79,796 C 91.789666,801.15806 92.441502,806.29547 93.73,811.29 C 94.430192,814.00083 95.315606,816.66042 96.38,819.25 C 97.276438,821.43051 98.298142,823.55739 99.44,825.62 C 94.422301,826.91574 89.157699,826.91574 84.14,825.62 C 83.279068,825.39718 82.42826,825.13694 81.59,824.84 C 77.552511,823.41294 73.859549,821.15424 70.75,818.21 C 70.083968,817.57897 69.446657,816.9183 68.84,816.23 C 67.4955,814.70535 66.30629,813.05051 65.29,811.29 C 62.605686,806.64125 61.191691,801.36809 61.19,796 z "
class="st1"
id="path2288"
style="fill:#99ccff;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
style="stroke:none;stroke-opacity:1"
id="shape4-6"
v:mID="4"
v:groupContext="shape"
transform="translate(198.9204,-422.965)"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2291">Sheet.4</title>
<path
d="M 47.81,838.54 C 44.069155,834.67238 40.854769,830.32825 38.25,825.62 C 33.233333,816.5536 30.601077,806.36178 30.6,796 L 0,796 C 0.0019883187,804.40192 3.4589958,812.43332 9.56,818.21 C 7.0683158,822.71453 3.8365461,826.76777 -3.5667036e-014,830.2 C 3.9485244,833.73199 8.4787648,836.55366 13.39,838.54 C 18.858079,840.75226 24.701356,841.88968 30.6,841.89 C 36.498644,841.88968 42.341921,840.75226 47.81,838.54 L 47.81,838.54 z "
class="st1"
id="path2293"
style="fill:#99ccff;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
id="shape6-10"
v:mID="6"
v:groupContext="shape"
transform="translate(291.16752,-422.77482)"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2301">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2303"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
style="stroke:none;stroke-opacity:1"
id="shape8-15"
v:mID="8"
v:groupContext="shape"
transform="translate(321.3044,-438.2631)"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2313">Sheet.8</title>
<path
d="M 0.66,804.97 C 0.22124193,807.04805 4.9337977e-005,809.16614 -8.4213233e-016,811.29 C -0.00173203,823.19594 6.9033391,834.02169 17.7,839.04 C 19.389124,839.82517 21.146421,840.45445 22.95,840.92 C 32.112714,843.28407 41.853704,841.27543 49.333795,835.47954 C 56.813885,829.68364 61.191238,820.75278 61.19,811.29 C 61.188145,801.82898 56.809491,792.901 49.329842,787.1074 C 41.850193,781.3138 32.111014,779.30637 22.95,781.67 C 11.698204,784.57362 3.0624758,793.60065 0.66,804.97 L 0.66,804.97 z "
class="st1"
id="path2315"
style="fill:#99ccff;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
style="stroke:none;stroke-opacity:1"
id="shape9-17"
v:mID="9"
v:groupContext="shape"
transform="translate(244.8144,-434.6517)"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2318">Sheet.9</title>
<path
d="M 27.18,783.49 C 30.37046,781.1256 33.986249,779.39749 37.83,778.4 C 47.926884,775.79129 58.657172,778.50496 66.3,785.6 C 66.369401,785.473 66.439402,785.34634 66.51,785.22 C 68.139028,782.30777 69.755833,780.06867 71.975351,777.57698 L 75.762541,773.51888 C 76.9704,772.83669 74.666372,773.66976 76.150703,773.26302 C 74.017571,771.68987 75.329915,772.78466 75.088378,772.5107 C 71.389442,769.29521 68.011435,767.3416 63.49,765.45 C 57.914597,763.11726 51.933717,761.90749 45.89,761.89 C 41.970674,761.87571 38.065628,762.363 34.27,763.34 C 29.730068,764.51346 25.396538,766.37502 21.42,768.86 C 19.249037,770.21628 17.195223,771.75162 15.28,773.45 C 14.00412,774.58169 12.792244,775.78356 11.65,777.05 C 9.3432484,779.60319 7.3306275,782.40744 5.65,785.41 C 4.4101058,787.62889 3.3564901,789.94684 2.5,792.34 C 0.88804139,797.29563 0.044924941,802.46899 3.7470027e-016,807.68 C 0.00072628219,815.45325 1.9758087,823.09895 5.74,829.9 C 8.2316842,834.40453 11.463454,838.45777 15.3,841.89 C 16.569383,840.75458 17.77458,839.54938 18.91,838.28 C 21.091288,835.84112 23.005505,833.17597 24.62,830.33 C 24.700768,830.1871 24.78077,830.04376 24.86,829.9 C 18.756473,824.12093 15.299242,816.0854 15.3,807.68 L 61.19,807.68 C 61.191474,802.46766 62.080862,797.29365 63.82,792.38 L 19.4,792.38 C 20.593932,790.15426 22.125421,788.1269 23.94,786.37 C 24.243724,786.06684 24.553793,785.77011 24.87,785.48 C 25.606291,784.77851 26.377257,784.11435 27.18,783.49 L 27.18,783.49 z "
class="st1"
id="path2320"
style="fill:#99ccff;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
sodipodi:nodetypes="cccsccccsccssssccccssccccccccc" />
</g><g
id="g2184"
v:mID="6"
v:groupContext="shape"
transform="translate(353.50185,-422.77482)"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2186">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2188"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
id="g2190"
v:mID="6"
v:groupContext="shape"
transform="translate(229.31375,-422.77483)"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:export-filename="L:\wafosvn\wafo\data\wafoLogoNewWithoutBorder.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2192">Sheet.6</title>
<path
d="M 61.19,841.89 C 55.291356,841.88968 49.448079,840.75226 43.98,838.54 C 39.072299,836.55264 34.545515,833.73101 30.6,830.2 C 23.504453,836.54775 14.61042,840.53172 5.15,841.6 C 3.4401274,841.79314 1.7207458,841.88996 4.5062722e-016,841.89 L 61.19,841.89 z "
class="st1"
id="path2194"
style="fill:#195fdd;fill-opacity:1;stroke:none;stroke-width:0.72000003;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
</g><g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="W"
style="opacity:0.57471266" /><g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="WAVE"
sodipodi:insensitive="true" /></svg>

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

File diff suppressed because it is too large Load Diff

@ -1,310 +0,0 @@
"""
WAFO defintions and numenclature
crossings :
cycle_pairs :
turning_points :
wave_amplitudes :
wave_periods :
waves :
Examples
--------
In order to view the documentation do the following in an ipython window:
import wafo.definitions as wd
wd.crossings()
or
wd.crossings?
"""
def wave_amplitudes():
r"""
Wave amplitudes and heights definitions and nomenclature
Definition of wave amplitudes and wave heights
---------------------------------------------
<----- Direction of wave propagation
|..............c_..........|
| /| \ |
Hd | _/ | \ | Hu
M | / | \ |
/ \ | M / Ac | \_ | c_
F \ | / \m/ | \ | / \
------d----|---u------------------d---|---u----d------ level v
\ | /| \ | / \L
\_ | / | At \_|_/
\|/..| t
t
Parameters
----------
Ac : crest amplitude
At : trough amplitude
Hd : wave height as defined for down crossing waves
Hu : wave height as defined for up crossing waves
See also
--------
waves, crossings, turning_points
"""
print(wave_amplitudes.__doc__)
def crossings():
r"""
Level v crossing definitions and nomenclature
Definition of level v crossings
-------------------------------
M
. . M M
. . . . . .
F d . . L
-----------------------u-------d-------o----------------- level v
. . . . u
. m
m
Let the letters 'm', 'M', 'F', 'L','d' and 'u' in the
figure above denote local minimum, maximum, first value, last
value, down- and up-crossing, respectively. The remaining
sampled values are indicated with a '.'. Values that are identical
with v, but do not cross the level is indicated with the letter 'o'.
We have a level up-crossing at index, k, if
x(k) < v and v < x(k+1)
or if
x(k) == v and v < x(k+1) and x(r) < v for some di < r <= k-1
where di is the index to the previous downcrossing.
Similarly there is a level down-crossing at index, k, if
x(k) > v and v > x(k+1)
or if
x(k) == v and v > x(k+1) and x(r) > v for some ui < r <= k-1
where ui is the index to the previous upcrossing.
The first (F) value is a up crossing if x(1) = v and x(2) > v.
Similarly, it is a down crossing if x(1) = v and x(2) < v.
See also
--------
wave_periods, waves, turning_points, findcross, findtp
"""
print(crossings.__doc__)
def cycle_pairs():
r"""
Cycle pairs definitions and numenclature
Definition of Max2min and min2Max cycle pair
--------------------------------------------
A min2Max cycle pair (mM) is defined as the pair of a minimum
and the following Maximum. Similarly a Max2min cycle pair (Mm)
is defined as the pair of a Maximum and the following minimum.
(all turning points possibly rainflowfiltered before pairing into cycles.)
See also
--------
turning_points
"""
print(cycle_pairs.__doc__)
def wave_periods():
r"""
Wave periods (lengths) definitions and nomenclature
Definition of wave periods (lengths)
------------------------------------
<----- Direction of wave propagation
<-------Tu--------->
: :
<---Tc-----> :
: : : <------Tcc---->
M : c : : : :
/ \ : M / \_ : : c_ c
F \ :/ \m/ \: :/ \ / \
------d--------u----------d-------u----d--------u---d-------- level v
\ / \ / :\_ _/: :\_ L
\_ / \_t_/ : \t_/ : : \m/
\t/ : : : :
: : <---Tt---> :
<--------Ttt-------> : :
<-----Td----->
Tu = Up crossing period
Td = Down crossing period
Tc = Crest period, i.e., period between up crossing and
the next down crossing
Tt = Trough period, i.e., period between down crossing and
the next up crossing
Ttt = Trough2trough period
Tcc = Crest2crest period
<----- Direction of wave propagation
<--Tcf-> Tuc
: : <-Tcb-> <->
M : c : : : :
/ \ : M / \_ c_ : : c
F \ :/ \m/ \ / \___: :/ \
------d---------u----------d---------u-------d--------u---d------ level v
:\_ / \ __/: \_ _/ \_ L
: \_ / \_t_/ : \t_/ \m/
: \t/ : :
: : : :
<-Ttf-> <-Ttb->
Tcf = Crest front period, i.e., period between up crossing and crest
Tcb = Crest back period, i.e., period between crest and down crossing
Ttf = Trough front period, i.e., period between down crossing and trough
Ttb = Trough back period, i.e., period between trough and up crossing
Also note that Tcf and Ttf can also be abbreviated by their crossing
marker, e.g. Tuc (u2c) and Tdt (d2t), respectively. Similar applies
to all the other wave periods and wave lengths.
(The nomenclature for wave length is similar, just substitute T and
period with L and length, respectively)
<----- Direction of wave propagation
<--TMm-->
<-TmM-> : :
M : : M :
/ \ : M /:\_ : M_ M
F \ : / \m/ : \ : /: \ / \
\ : / : \ : / : \ / \
\ : / : \ : / : \_ _/ \_ L
\_ : / : \_m_/ : \m_/ \m/
\m/ : : : :
<-----TMM-----> <----Tmm----->
TmM = Period between minimum and the following Maximum
TMm = Period between Maximum and the following minimum
TMM = Period between Maximum and the following Maximum
Tmm = Period between minimum and the following minimum
See also
--------
waves,
wave_amplitudes,
crossings,
turning_points
"""
print(wave_periods.__doc__)
def turning_points():
r"""
Turning points definitions and numenclature
Definition of turningpoints
---------------------------
<----- Direction of wave propagation
M M
/ \ .... M /:\_ M_ M
F \ | / \m/ : \ /: \ / \
\ h | / : \ / : \ / \
\ | / : \ / : \_ _/ \_ L
\_ | / : \_m_/ : \m_/ \m/
\m/ : : : :
<------Mw-----> <-----mw----->
Local minimum or maximum are indicated with the
letters 'm' or 'M'. Turning points in this connection are all
local max (M) and min (m) and the last (L) value and the
first (F) value if the first local extremum is a max.
(This choice is made in order to get the exact up-crossing intensity
from rfc by mm2lc(tp2mm(rfc)) )
See also
--------
waves,
crossings,
cycle_pairs
findtp
"""
print(turning_points.__doc__)
def waves():
r"""
Wave definitions and nomenclature
Definition of trough and crest
------------------------------
A trough (t) is defined as the global minimum between a
level v down-crossing (d) and the next up-crossing (u)
and a crest (c) is defined as the global maximum between a
level v up-crossing and the following down-crossing.
Definition of down- and up -crossing waves
------------------------------------------
A level v-down-crossing wave (dw) is a wave from a
down-crossing to the following down-crossing.
Similarly, a level v-up-crossing wave (uw) is a wave from an up-crossing
to the next up-crossing.
Definition of trough and crest waves
------------------------------------
A trough-to-trough wave (tw) is a wave from a trough (t) to the
following trough. The crest-to-crest wave (cw) is defined similarly.
Definition of min2min and Max2Max wave
--------------------------------------
A min2min wave (mw) is defined starting from a minimum (m) and
ending in the following minimum.
Similarly a Max2Max wave (Mw) is thus a wave from a maximum (M)
to the next maximum (all waves optionally rainflow filtered).
<----- Direction of wave propagation
<------Mw-----> <----mw---->
M : : c :
/ \ M : / \_ : c_ c
F \ / \m/ \ : /: \ /:\
------d--------u----------d-------u----d--------u---d------ level v
\ /: \ : /: : :\_ _/ : :\_ L
\_ / : \_t_/ : : : \t_/ : : \m/
\t/ <-------uw---------> : <-----dw----->
: : : :
<--------tw--------> <------cw----->
(F=first value and L=last value).
See also
--------
turning_points,
crossings,
wave_periods
findtc,
findcross
"""
print(waves.__doc__)
if __name__ == '__main__':
import doctest
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)

@ -1,146 +0,0 @@
"""
Created on 20. jan. 2011
@author: pab
"""
import numpy as np
from numpy import exp, meshgrid
__all__ = ['peaks', 'humps', 'magic']
def _magic_odd_order(n):
ix = np.arange(n) + 1
J, I = np.meshgrid(ix, ix)
A = np.mod(I + J - (n + 3) / 2, n)
B = np.mod(I + 2 * J - 2, n)
M = n * A + B + 1
return M
def _magic_doubly_even_order(n):
M = np.arange(1, n * n + 1).reshape(n, n)
ix = np.mod(np.arange(n) + 1, 4) // 2
J, I = np.meshgrid(ix, ix)
iz = np.flatnonzero(I == J)
M.put(iz, n * n + 1 - M.flat[iz])
return M
def _magic_even_order(n):
p = n // 2
M0 = magic(p)
M = np.hstack((np.vstack((M0, M0 + 3 * p * p)),
np.vstack((M0 + 2 * p * p, M0 + p * p))))
if n > 2:
k = (n - 2) // 4
jvec = np.hstack((np.arange(k), np.arange(n - k + 1, n)))
for i in range(p):
for j in jvec:
temp = M[i][j]
M[i][j] = M[i + p][j]
M[i + p][j] = temp
i = k
j = 0
temp = M[i][j]
M[i][j] = M[i + p][j]
M[i + p][j] = temp
j = i
temp = M[i + p][j]
M[i + p][j] = M[i][j]
M[i][j] = temp
return M
def magic(n):
"""
Return magic square for n of any orders > 2.
A magic square has the property that the sum of every row and column,
as well as both diagonals, is the same number.
Examples
--------
>>> np.allclose(magic(3),
... [[8, 1, 6],
... [3, 5, 7],
... [4, 9, 2]])
True
>>> np.allclose(magic(4),
... [[16, 2, 3, 13],
... [ 5, 11, 10, 8],
... [ 9, 7, 6, 12],
... [ 4, 14, 15, 1]])
True
>>> np.allclose(magic(6),
... [[35, 1, 6, 26, 19, 24],
... [ 3, 32, 7, 21, 23, 25],
... [31, 9, 2, 22, 27, 20],
... [ 8, 28, 33, 17, 10, 15],
... [30, 5, 34, 12, 14, 16],
... [ 4, 36, 29, 13, 18, 11]])
True
"""
if (n < 3):
raise ValueError('n must be greater than 2.')
if np.mod(n, 2) == 1:
return _magic_odd_order(n)
elif np.mod(n, 4) == 0:
return _magic_doubly_even_order(n)
return _magic_even_order(n)
def peaks(x=None, y=None, n=51):
"""
Return the "well" known MatLab (R) peaks function
evaluated in the [-3,3] x,y range
Example
-------
>>> import matplotlib.pyplot as plt
>>> x,y,z = peaks()
h = plt.contourf(x,y,z)
"""
if x is None:
x = np.linspace(-3, 3, n)
if y is None:
y = np.linspace(-3, 3, n)
[x1, y1] = meshgrid(x, y)
z = (3 * (1 - x1) ** 2 * exp(-(x1 ** 2) - (y1 + 1) ** 2) -
10 * (x1 / 5 - x1 ** 3 - y1 ** 5) * exp(-x1 ** 2 - y1 ** 2) -
1. / 3 * exp(-(x1 + 1) ** 2 - y1 ** 2))
return x1, y1, z
def humps(x=None):
"""
Computes a function that has three roots, and some humps.
Example
-------
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0,1)
>>> y = humps(x)
h = plt.plot(x,y)
"""
if x is None:
y = np.linspace(0, 1)
else:
y = np.asarray(x)
return 1.0 / ((y - 0.3) ** 2 + 0.01) + 1.0 / ((y - 0.9) ** 2 + 0.04) + \
2 * y - 5.2
if __name__ == '__main__':
from wafo.testing import test_docstrings
test_docstrings(__file__)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,73 +0,0 @@
{
"metadata": {
"name": "WAFO Chapter 3"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"CHAPTER3 Demonstrates distributions of wave characteristics\n",
"=============================================================\n",
"\n",
"Chapter3 contains the commands used in Chapter3 in the tutorial.\n",
" \n",
"Some of the commands are edited for fast computation. \n",
"\n",
"Section 3.2 Estimation of wave characteristics from data\n",
"----------------------------------------------------------\n",
"Example 1\n",
"~~~~~~~~~~ "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"speed = 'fast'\n",
"#speed = 'slow'\n",
"\n",
"import wafo.data as wd\n",
"import wafo.misc as wm\n",
"import wafo.objects as wo\n",
"xx = wd.sea() \n",
"xx[:,1] = wm.detrendma(xx[:,1],len(xx))\n",
"ts = wo.mat2timeseries(xx)\n",
"Tcrcr, ix = ts.wave_periods(vh=0, pdef='c2c', wdef='tw', rate=8)\n",
"Tc, ixc = ts.wave_periods(vh=0, pdef='u2d', wdef='tw', rate=8)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AssertionError",
"evalue": "",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-12-5b70e90102e6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[0mxx\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdetrendma\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxx\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[0mts\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmat2timeseries\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mxx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0mTcrcr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mix\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mts\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwave_periods\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvh\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpdef\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'c2c'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwdef\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'tw'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrate\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m8\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 11\u001b[0m \u001b[0mTc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mixc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mts\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwave_periods\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvh\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpdef\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'u2d'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwdef\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'tw'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrate\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m8\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\pab\\workspace\\pywafo_svn\\pywafo\\src\\wafo\\objects.pyc\u001b[0m in \u001b[0;36mwave_periods\u001b[1;34m(self, vh, pdef, wdef, index, rate)\u001b[0m\n\u001b[0;32m 1980\u001b[0m \u001b[0mn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mceil\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msize\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mrate\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1981\u001b[0m \u001b[0mti\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlinspace\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mn\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1982\u001b[1;33m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mstineman_interp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mti\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1983\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1984\u001b[0m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Python27\\lib\\site-packages\\matplotlib\\mlab.pyc\u001b[0m in \u001b[0;36mstineman_interp\u001b[1;34m(xi, x, y, yp)\u001b[0m\n\u001b[0;32m 2932\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat_\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2933\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat_\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2934\u001b[1;33m \u001b[1;32massert\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2935\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2936\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0myp\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mAssertionError\u001b[0m: "
]
}
],
"prompt_number": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,192 +0,0 @@
import wafo.plotbackend.plotbackend as plt
import numpy as np
# pyreport -o chapter1.html chapter1.py
#! CHAPTER1 demonstrates some applications of WAFO
#!================================================
#!
#! CHAPTER1 gives an overview through examples some of the capabilities of
#! WAFO. WAFO is a toolbox of Matlab routines for statistical analysis and
#! simulation of random waves and loads.
#!
#! The commands are edited for fast computation.
#! Section 1.4 Some applications of WAFO
#!---------------------------------------
#! Section 1.4.1 Simulation from spectrum, estimation of spectrum
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Simulation of the sea surface from spectrum
#! The following code generates 200 seconds of data sampled with 10Hz from
#! the Torsethaugen spectrum
import wafo.spectrum.models as wsm
S = wsm.Torsethaugen(Hm0=6, Tp=8)
S1 = S.tospecdata()
S1.plot()
plt.show()
##
import wafo.objects as wo
xs = S1.sim(ns=2000, dt=0.1)
ts = wo.mat2timeseries(xs)
ts.plot_wave('-')
plt.show()
#! Estimation of spectrum
#!~~~~~~~~~~~~~~~~~~~~~~~
#! A common situation is that one wants to estimate the spectrum for wave
#! measurements. The following code simulate 20 minutes signal sampled at 4Hz
#! and compare the spectral estimate with the original Torsethaugen spectum.
plt.clf()
Fs = 4
xs = S1.sim(ns=np.fix(20 * 60 * Fs), dt=1. / Fs)
ts = wo.mat2timeseries(xs)
Sest = ts.tospecdata(L=400)
S1.plot()
Sest.plot('--')
plt.axis([0, 3, 0, 5])
plt.show()
#! Section 1.4.2 Probability distributions of wave characteristics.
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Probability distribution of wave trough period:
#! WAFO gives the possibility of computing the exact probability
#! distributions for a number of characteristics given a spectral density.
#! In the following example we study the trough period extracted from the
#! time series and compared with the theoretical density computed with exact
#! spectrum, S1, and the estimated spectrum, Sest.
plt.clf()
import wafo.misc as wm
dtyex = S1.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)
dtyest = Sest.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)
T, index = ts.wave_periods(vh=0, pdef='d2u')
bins = wm.good_bins(T, num_bins=25, odd=True)
wm.plot_histgrm(T, bins=bins, normed=True)
dtyex.plot()
dtyest.plot('-.')
plt.axis([0, 10, 0, 0.35])
plt.show()
#! Section 1.4.3 Directional spectra
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Here are a few lines of code, which produce directional spectra
#! with frequency independent and frequency dependent spreading.
plt.clf()
plotflag = 1
Nt = 101 # number of angles
th0 = np.pi / 2 # primary direction of waves
Sp = 15 # spreading parameter
D1 = wsm.Spreading(type='cos', theta0=th0, method=None)
D12 = wsm.Spreading(type='cos', theta0=0, method='mitsuyasu')
SD1 = D1.tospecdata2d(S1)
SD12 = D12.tospecdata2d(S1)
SD1.plot()
SD12.plot() # linestyle='dashdot')
plt.show()
#! 3D Simulation of the sea surface
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! The simulations show that frequency dependent spreading leads to
#! much more irregular surface so the orientation of waves is less
#! transparent compared to the frequency independent case.
#
#! Frequency independent spreading
#plotflag = 1; iseed = 1;
#
#Nx = 2 ^ 8;Ny = Nx;Nt = 1;dx = 0.5; dy = dx; dt = 0.25; fftdim = 2;
#randn('state', iseed)
#Y1 = seasim(SD1, Nx, Ny, Nt, dx, dy, dt, fftdim, plotflag);
#wafostamp('', '(ER)')
#axis('fill')
#disp('Block = 6'), pause(pstate)
#
###
## Frequency dependent spreading
#randn('state', iseed)
#Y12 = seasim(SD12, Nx, Ny, Nt, dx, dy, dt, fftdim, plotflag);
#wafostamp('', '(ER)')
#axis('fill')
#disp('Block = 7'), pause(pstate)
#
#! Estimation of directional spectrum
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! The figure is not shown in the Tutorial
#
# Nx = 3; Ny = 2; Nt = 2 ^ 12; dx = 10; dy = 10;dt = 0.5;
# F = seasim(SD12, Nx, Ny, Nt, dx, dy, dt, 1, 0);
# Z = permute(F.Z, [3 1 2]);
# [X, Y] = meshgrid(F.x, F.y);
# N = Nx * Ny;
# types = repmat(sensortypeid('n'), N, 1);
# bfs = ones(N, 1);
# pos = [X(:), Y(:), zeros(N, 1)];
# h = inf;
# nfft = 128;
# nt = 101;
# SDe = dat2dspec([F.t Z(:, :)], [pos types, bfs], h, nfft, nt);
#plotspec(SDe), hold on
#plotspec(SD12, '--'), hold off
#disp('Block = 8'), pause(pstate)
#! Section 1.4.4 Fatigue, Load cycles and Markov models.
#! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Switching Markow chain of turningpoints
#! In fatigue applications the exact sample path is not important, but
#! only the tops and bottoms of the load, called the sequence of turning
#! points (TP). From the turning points one can extract load cycles, from
#! which damage calculations and fatigue life predictions can be
#! performed.
#!
#! The commands below computes the intensity of rainflowcycles for
#! the Gaussian model with spectrum S1 using the Markov approximation.
#! The rainflow cycles found in the simulated load signal are shown in the
#! figure.
#clf()
#paramu = [-6 6 61];
#frfc = spec2cmat(S1, [], 'rfc', [], paramu);
#pdfplot(frfc);
#hold on
#tp = dat2tp(xs);
#rfc = tp2rfc(tp);
#plot(rfc(:, 2), rfc(:, 1), '.')
#wafostamp('', '(ER)')
#hold off
#disp('Block = 9'), pause(pstate)
#! Section 1.4.5 Extreme value statistics
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Plot of yura87 data
plt.clf()
import wafo.data as wd
xn = wd.yura87()
#xn = load('yura87.dat');
plt.subplot(211)
plt.plot(xn[::30, 0] / 3600, xn[::30, 1], '.')
plt.title('Water level')
plt.ylabel('(m)')
#! Formation of 5 min maxima
yura = xn[:85500, 1]
yura = np.reshape(yura, (285, 300)).T
maxyura = yura.max(axis=0)
plt.subplot(212)
plt.plot(xn[299:85500:300, 0] / 3600, maxyura, '.')
plt.xlabel('Time (h)')
plt.ylabel('(m)')
plt.title('Maximum 5 min water level')
plt.show()
#! Estimation of GEV for yuramax
plt.clf()
import wafo.stats as ws
phat = ws.genextreme.fit2(maxyura, method='ml')
phat.plotfitsummary()
plt.show()
#disp('Block = 11, Last block')

@ -1,327 +0,0 @@
import wafo.plotbackend.plotbackend as plt
import numpy as np
# pyreport -o chapter2.html chapter2.py
#! CHAPTER2 Modelling random loads and stochastic waves
#!=======================================================
#!
#! Chapter2 contains the commands used in Chapter 2 of the tutorial and
#! present some tools for analysis of random functions with
#! respect to their correlation, spectral and distributional properties.
#! The presentation is divided into three examples:
#!
#! Example1 is devoted to estimation of different parameters in the model.
#! Example2 deals with spectral densities and
#! Example3 presents the use of WAFO to simulate samples of a Gaussian
#! process.
#!
#! Some of the commands are edited for fast computation.
#!
#! Section 2.1 Introduction and preliminary analysis
#!====================================================
#! Example 1: Sea data
#!----------------------
#! Observed crossings compared to the expected for Gaussian signals
import wafo
import wafo.objects as wo
xx = wafo.data.sea()
me = xx[:, 1].mean()
sa = xx[:, 1].std()
xx[:, 1] -= me
ts = wo.mat2timeseries(xx)
tp = ts.turning_points()
cc = tp.cycle_pairs()
lc = cc.level_crossings()
lc.plot()
plt.show()
#! Average number of upcrossings per time unit
#!----------------------------------------------
#! Next we compute the mean frequency as the average number of upcrossings
#! per time unit of the mean level (= 0); this may require interpolation in the
#! crossing intensity curve, as follows.
T = xx[:, 0].max() - xx[:, 0].min()
f0 = np.interp(0, lc.args, lc.data, 0) / T # zero up-crossing frequency
print('f0 = %g' % f0)
#! Turningpoints and irregularity factor
#!----------------------------------------
fm = len(tp.data) / (2 * T) # frequency of maxima
alfa = f0 / fm # approx Tm24/Tm02
print('fm = %g, alpha = %g, ' % (fm, alfa))
#! Visually examine data
#!------------------------
#! We finish this section with some remarks about the quality
#! of the measured data. Especially sea surface measurements can be
#! of poor quality. We shall now check the quality of the dataset {\tt xx}.
#! It is always good practice to visually examine the data
#! before the analysis to get an impression of the quality,
#! non-linearities and narrow-bandedness of the data.
#! First we shall plot the data and zoom in on a specific region.
#! A part of sea data is visualized with the following commands
plt.clf()
ts.plot_wave('k-', tp, '*', nfig=1, nsub=1)
plt.axis([0, 2, -2, 2])
plt.show()
#! Finding possible spurious points
#!------------------------------------
#! However, if the amount of data is too large for visual examinations one
#! could use the following criteria to find possible spurious points. One
#! must be careful using the criteria for extremevalue analysis, because
#! it might remove extreme waves that are OK and not spurious.
import wafo.misc as wm
dt = ts.sampling_period()
# dt = np.diff(xx[:2,0])
dcrit = 5 * dt
ddcrit = 9.81 / 2 * dt * dt
zcrit = 0
inds, indg = wm.findoutliers(ts.data, zcrit, dcrit, ddcrit, verbose=True)
#! Section 2.2 Frequency Modeling of Load Histories
#!----------------------------------------------------
#! Periodogram: Raw spectrum
#!
plt.clf()
Lmax = 9500
S = ts.tospecdata(L=Lmax)
S.plot()
plt.axis([0, 5, 0, 0.7])
plt.show()
#! Calculate moments
#!-------------------
mom, text = S.moment(nr=4)
print('sigma = %g, m0 = %g' % (sa, np.sqrt(mom[0])))
#! Section 2.2.1 Random functions in Spectral Domain - Gaussian processes
#!--------------------------------------------------------------------------
#! Smoothing of spectral estimate
#!----------------------------------
#! By decreasing Lmax the spectrum estimate becomes smoother.
plt.clf()
Lmax0 = 200
Lmax1 = 50
S1 = ts.tospecdata(L=Lmax0)
S2 = ts.tospecdata(L=Lmax1)
S1.plot('-.')
S2.plot()
plt.show()
#! Estimated autocovariance
#!----------------------------
#! Obviously knowing the spectrum one can compute the covariance
#! function. The following code will compute the covariance for the
#! unimodal spectral density S1 and compare it with estimated
#! covariance of the signal xx.
plt.clf()
Lmax = 85
R1 = S1.tocovdata(nr=1)
Rest = ts.tocovdata(lag=Lmax)
R1.plot('.')
Rest.plot()
plt.axis([0, 25, -0.1, 0.25])
plt.show()
#! We can see in Figure below that the covariance function corresponding to
#! the spectral density S2 significantly differs from the one estimated
#! directly from data.
#! It can be seen in Figure above that the covariance corresponding to S1
#! agrees much better with the estimated covariance function
plt.clf()
R2 = S2.tocovdata(nr=1)
R2.plot('.')
Rest.plot()
plt.show()
#! Section 2.2.2 Transformed Gaussian models
#!-------------------------------------------
#! We begin with computing skewness and kurtosis
#! for the data set xx and compare it with the second order wave approximation
#! proposed by Winterstein:
import wafo.stats as ws
rho3 = ws.skew(xx[:, 1])
rho4 = ws.kurtosis(xx[:, 1])
sk, ku = S1.stats_nl(moments='sk')
#! Comparisons of 3 transformations
plt.clf()
import wafo.transform.models as wtm
gh = wtm.TrHermite(mean=me, sigma=sa, skew=sk, kurt=ku).trdata()
g = wtm.TrLinear(mean=me, sigma=sa).trdata() # Linear transformation
glc, gemp = lc.trdata(mean=me, sigma=sa)
glc.plot('b-') # Transf. estimated from level-crossings
gh.plot('b-.') # Hermite Transf. estimated from moments
g.plot('r')
plt.grid('on')
plt.show()
#! Test Gaussianity of a stochastic process
#!------------------------------------------
#! TESTGAUSSIAN simulates e(g(u)-u) = int (g(u)-u)^2 du for Gaussian processes
#! given the spectral density, S. The result is plotted if test0 is given.
#! This is useful for testing if the process X(t) is Gaussian.
#! If 95% of TEST1 is less than TEST0 then X(t) is not Gaussian at a 5% level.
#!
#! As we see from the figure below: none of the simulated values of test1 is
#! above 1.00. Thus the data significantly departs from a Gaussian distribution.
plt.clf()
test0 = glc.dist2gauss()
#! the following test takes time
N = len(xx)
test1 = S1.testgaussian(ns=N, cases=50, test0=test0)
is_gaussian = sum(test1 > test0) > 5
print(is_gaussian)
plt.show()
#! Normalplot of data xx
#!------------------------
#! indicates that the underlying distribution has a "heavy" upper tail and a
#! "light" lower tail.
plt.clf()
import pylab
ws.probplot(ts.data.ravel(), dist='norm', plot=pylab)
plt.show()
#! Section 2.2.3 Spectral densities of sea data
#!-----------------------------------------------
#! Example 2: Different forms of spectra
#!
import wafo.spectrum.models as wsm
plt.clf()
Hm0 = 7
Tp = 11
spec = wsm.Jonswap(Hm0=Hm0, Tp=Tp).tospecdata()
spec.plot()
plt.show()
#! Directional spectrum and Encountered directional spectrum
#! Directional spectrum
plt.clf()
D = wsm.Spreading('cos2s')
Sd = D.tospecdata2d(spec)
Sd.plot()
plt.show()
##!Encountered directional spectrum
##!---------------------------------
#clf()
#Se = spec2spec(Sd,'encdir',0,10);
#plotspec(Se), hold on
#plotspec(Sd,1,'--'), hold off
##!wafostamp('','(ER)')
#disp('Block = 17'),pause(pstate)
#
##!#! Frequency spectra
#clf
#Sd1 =spec2spec(Sd,'freq');
#Sd2 = spec2spec(Se,'enc');
#plotspec(spec), hold on
#plotspec(Sd1,1,'.'),
#plotspec(Sd2),
##!wafostamp('','(ER)')
#hold off
#disp('Block = 18'),pause(pstate)
#
##!#! Wave number spectrum
#clf
#Sk = spec2spec(spec,'k1d')
#Skd = spec2spec(Sd,'k1d')
#plotspec(Sk), hold on
#plotspec(Skd,1,'--'), hold off
##!wafostamp('','(ER)')
#disp('Block = 19'),pause(pstate)
#
##!#! Effect of waterdepth on spectrum
#clf
#plotspec(spec,1,'--'), hold on
#S20 = spec;
#S20.S = S20.S.*phi1(S20.w,20);
#S20.h = 20;
#plotspec(S20), hold off
##!wafostamp('','(ER)')
#disp('Block = 20'),pause(pstate)
#
##!#! Section 2.3 Simulation of transformed Gaussian process
##!#! Example 3: Simulation of random sea
##! The reconstruct function replaces the spurious points of seasurface by
##! simulated data on the basis of the remaining data and a transformed Gaussian
##! process. As noted previously one must be careful using the criteria
##! for finding spurious points when reconstructing a dataset, because
##! these criteria might remove the highest and steepest waves as we can see
##! in this plot where the spurious points is indicated with a '+' sign:
##!
#clf
#[y, grec] = reconstruct(xx,inds);
#waveplot(y,'-',xx(inds,:),'+',1,1)
#axis([0 inf -inf inf])
##!wafostamp('','(ER)')
#disp('Block = 21'),pause(pstate)
#
##! Compare transformation (grec) from reconstructed (y)
##! with original (glc) from (xx)
#clf
#trplot(g), hold on
#plot(gemp(:,1),gemp(:,2))
#plot(glc(:,1),glc(:,2),'-.')
#plot(grec(:,1),grec(:,2)), hold off
#disp('Block = 22'),pause(pstate)
#
##!#!
#clf
#L = 200;
#x = dat2gaus(y,grec);
#Sx = dat2spec(x,L);
#disp('Block = 23'),pause(pstate)
#
##!#!
#clf
#dt = spec2dt(Sx)
#Ny = fix(2*60/dt) #! = 2 minutes
#Sx.tr = grec;
#ysim = spec2sdat(Sx,Ny);
#waveplot(ysim,'-')
##!wafostamp('','(CR)')
#disp('Block = 24'),pause(pstate)
#
#! Estimated spectrum compared to Torsethaugen spectrum
#!-------------------------------------------------------
plt.clf()
fp = 1.1
dw = 0.01
H0 = S1.characteristic('Hm0')[0]
St = wsm.Torsethaugen(Hm0=H0,Tp=2*np.pi/fp).tospecdata(np.arange(0,5+dw/2,dw))
S1.plot()
St.plot('-.')
plt.axis([0, 6, 0, 0.4])
plt.show()
#! Transformed Gaussian model compared to Gaussian model
#!--------------------------------------------------------
dt = St.sampling_period()
va, sk, ku = St.stats_nl(moments='vsk')
#sa = sqrt(va)
gh = wtm.TrHermite(mean=me, sigma=sa, skew=sk, kurt=ku, ysigma=sa)
ysim_t = St.sim(ns=240, dt=0.5)
xsim_t = ysim_t.copy()
xsim_t[:, 1] = gh.gauss2dat(ysim_t[:, 1])
ts_y = wo.mat2timeseries(ysim_t)
ts_x = wo.mat2timeseries(xsim_t)
ts_y.plot_wave(sym1='r.', ts=ts_x, sym2='b', sigma=sa, nsub=5, nfig=1)
plt.show()

@ -1,615 +0,0 @@
from wafo.plotbackend import plotbackend as plt
import numpy as np
#! CHAPTER3 Demonstrates distributions of wave characteristics
#!=============================================================
#!
#! Chapter3 contains the commands used in Chapter3 in the tutorial.
#!
#! Some of the commands are edited for fast computation.
#!
#! Section 3.2 Estimation of wave characteristics from data
#!----------------------------------------------------------
#! Example 1
#!~~~~~~~~~~
speed = 'fast'
#speed = 'slow'
import scipy.signal as ss
import wafo.data as wd
import wafo.misc as wm
import wafo.objects as wo
import wafo.stats as ws
import wafo.spectrum.models as wsm
xx = wd.sea()
xx[:, 1] = ss.detrend(xx[:, 1])
ts = wo.mat2timeseries(xx)
Tcrcr, ix = ts.wave_periods(vh=0, pdef='c2c', wdef='tw', rate=8)
Tc, ixc = ts.wave_periods(vh=0, pdef='u2d', wdef='tw', rate=8)
#! Histogram of crestperiod compared to the kernel density estimate
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.kdetools as wk
plt.clf()
print(Tc.mean())
print(Tc.max())
t = np.linspace(0.01,8,200);
ftc = wk.TKDE(Tc, L2=0, inc=128)
plt.plot(t,ftc.eval_grid(t), t, ftc.eval_grid_fast(t),'-.')
wm.plot_histgrm(Tc, normed=True)
plt.title('Kernel Density Estimates')
plt.xlabel('Tc [s]')
plt.axis([0, 8, 0, 0.5])
plt.show()
#! Extreme waves - model check: the highest and steepest wave
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plt.clf()
S, H = ts.wave_height_steepness(kind=0)
indS = S.argmax()
indH = H.argmax()
ts.plot_sp_wave([indH, indS],'k.')
plt.show()
#! Does the highest wave contradict a transformed Gaussian model?
#!----------------------------------------------------------------
# TODO: Fix this
#clf
#inds1 = (5965:5974)'; #! points to remove
#Nsim = 10;
#[y1, grec1, g2, test, tobs, mu1o, mu1oStd] = ...
# reconstruct(xx,inds1,Nsim);
#spwaveplot(y1,indA-10)
#hold on
#plot(xx(inds1,1),xx(inds1,2),'+')
#lamb = 2.;
#muLstd = tranproc(mu1o-lamb*mu1oStd,fliplr(grec1));
#muUstd = tranproc(mu1o+lamb*mu1oStd,fliplr(grec1));
#plot (y1(inds1,1), [muLstd muUstd],'b-')
#axis([1482 1498 -1 3]),
#wafostamp([],'(ER)')
#disp('Block = 6'),
#pause(pstate)
#
##!#! Expected value (solid) compared to data removed
#clf
#plot(xx(inds1,1),xx(inds1,2),'+'), hold on
#mu = tranproc(mu1o,fliplr(grec1));
#plot(y1(inds1,1), mu), hold off
#disp('Block = 7'), pause(pstate)
#! Crest height PDF
#!------------------
#! Transform data so that kde works better
plt.clf()
wave_data = ts.wave_parameters()
Ac = wave_data['Ac']
L2 = 0.6
ws.probplot(Ac**L2, dist='norm', plot=plt)
plt.show()
#!#!
plt.clf()#
fac = wk.TKDE(Ac,L2=L2)(np.linspace(0.01,3,200), output='plot')
fac.plot()
# wafostamp([],'(ER)')
print(fac.integrate(a=0.01, b=3))
print(fac.integrate())
print('Block = 8'),
# pause(pstate)
#!#! Empirical crest height CDF
plt.clf()
Fac = fac.to_cdf()
Femp = ws.edf(Ac)
Fac.plot()
Femp.plot()
plt.axis([0, 2, 0, 1])
#wafostamp([],'(ER)')
#disp('Block = 9'), pause(pstate)
#!#! Empirical crest height CDF compared to a Transformed Rayleigh approximation
# facr = trraylpdf(fac.x{1},'Ac',grec1);
# Facr = cumtrapz(facr.x{1},facr.f);
# hold on
# plot(facr.x{1},Facr,'.')
# axis([1.25 2.25 0.95 1])
# wafostamp([],'(ER)')
# disp('Block = 10'), pause(pstate)
#!#! Joint pdf of crest period and crest amplitude
plt.clf()
Tcf = wave_data['Tcf']
Tcb = wave_data['Tcb']
Tc = Tcf + Tcb
fTcAc = wk.TKDE([Tc, Ac],L2=0.5, inc=256).eval_grid_fast(output='plot')
fTcAc.labels.labx = 'Tc [s]'
fTcAc.labels.laby = 'Ac [m]'
fTcAc.plot()
plt.hold(True)
plt.plot(Tc, Ac,'k.')
plt.hold(False)
plt.show()
#wafostamp([],'(ER)')
#disp('Block = 11'), pause(pstate)
#!#! Example 4: Simple wave characteristics obtained from Jonswap spectrum
plt.clf()
S = wsm.Jonswap(Hm0=5, Tp=10).tospecdata()
m, mt = S.moment(nr=4, even=False)
print(m)
print(mt)
# disp('Block = 12'), pause(pstate)
plt.clf()
S.bandwidth(['alpha'])
ch, Sa2, chtxt = S.characteristic(['Hm0', 'Tm02'])
# disp('Block = 13'), pause(pstate)
#!#! Section 3.3.2 Explicit form approximations of wave characteristic densities
#!#! Longuett-Higgins model for Tc and Ac
# plt.clf()
# t = np.linspace(0,15,100)
# h = np.linspace(0,6,100)
# flh = lh83pdf(t, h, [m[0],m[1], m[2])
# #disp('Block = 14'), pause(pstate)
#
# #!#! Transformed Longuett-Higgins model for Tc and Ac
# clf
# [sk, ku ]=spec2skew(S);
# sa = sqrt(m(1));
# gh = hermitetr([],[sa sk ku 0]);
# flhg = lh83pdf(t,h,[m(1),m(2),m(3)],gh);
# disp('Block = 15'), pause(pstate)
#!#! Cavanie model for Tc and Ac
# clf
# t = np.linspace(0,10,100);
# h = np.linspace(0,7,100);
# fcav = cav76pdf(t,h,[m(1) m(2) m(3) m(5)],[]);
# disp('Block = 16'), pause(pstate)
#
# #!#! Example 5 Transformed Rayleigh approximation of crest- vs trough- amplitude
# clf
# xx = load('sea.dat');
# x = xx;
# x(:,2) = detrend(x(:,2));
# SS = dat2spec2(x);
# [sk, ku, me, si ] = spec2skew(SS);
# gh = hermitetr([],[si sk ku me]);
# Hs = 4*si;
# r = (0:0.05:1.1*Hs)';
# fac_h = trraylpdf(r,'Ac',gh);
# fat_h = trraylpdf(r,'At',gh);
# h = (0:0.05:1.7*Hs)';
# facat_h = trraylpdf(h,'AcAt',gh);
# pdfplot(fac_h)
# hold on
# pdfplot(fat_h,'--')
# hold off
# wafostamp([],'(ER)')
# disp('Block = 17'), pause(pstate)
#
# #!#!
# clf
# TC = dat2tc(xx, me);
# tc = tp2mm(TC);
# Ac = tc(:,2);
# At = -tc(:,1);
# AcAt = Ac+At;
# disp('Block = 18'), pause(pstate)
#
# #!#!
# clf
# Fac_h = [fac_h.x{1} cumtrapz(fac_h.x{1},fac_h.f)];
# subplot(3,1,1)
# Fac = plotedf(Ac,Fac_h);
# hold on
# plot(r,1-exp(-8*r.^2/Hs^2),'.')
# axis([1. 2. 0.9 1])
# title('Ac CDF')
#
# Fat_h = [fat_h.x{1} cumtrapz(fat_h.x{1},fat_h.f)];
# subplot(3,1,2)
# Fat = plotedf(At,Fat_h);
# hold on
# plot(r,1-exp(-8*r.^2/Hs^2),'.')
# axis([1. 2. 0.9 1])
# title('At CDF')
#
# Facat_h = [facat_h.x{1} cumtrapz(facat_h.x{1},facat_h.f)];
# subplot(3,1,3)
# Facat = plotedf(AcAt,Facat_h);
# hold on
# plot(r,1-exp(-2*r.^2/Hs^2),'.')
# axis([1.5 3.5 0.9 1])
# title('At+Ac CDF')
#
# wafostamp([],'(ER)')
# disp('Block = 19'), pause(pstate)
#
# #!#! Section 3.4 Exact wave distributions in transformed Gaussian Sea
# #!#! Section 3.4.1 Density of crest period, crest length or encountered crest period
# clf
# S1 = torsethaugen([],[6 8],1);
# D1 = spreading(101,'cos',pi/2,[15],[],0);
# D12 = spreading(101,'cos',0,[15],S1.w,1);
# SD1 = mkdspec(S1,D1);
# SD12 = mkdspec(S1,D12);
# disp('Block = 20'), pause(pstate)
#
# #!#! Crest period
# clf
# tic
# f_tc = spec2tpdf(S1,[],'Tc',[0 11 56],[],4);
# toc
# pdfplot(f_tc)
# wafostamp([],'(ER)')
# simpson(f_tc.x{1},f_tc.f)
# disp('Block = 21'), pause(pstate)
#
# #!#! Crest length
#
# if strncmpi(speed,'slow',1)
# opt1 = rindoptset('speed',5,'method',3);
# opt2 = rindoptset('speed',5,'nit',2,'method',0);
# else
# #! fast
# opt1 = rindoptset('speed',7,'method',3);
# opt2 = rindoptset('speed',7,'nit',2,'method',0);
# end
#
#
# clf
# if strncmpi(speed,'slow',1)
# NITa = 5;
# else
# disp('NIT=5 may take time, running with NIT=3 in the following')
# NITa = 3;
# end
# #!f_Lc = spec2tpdf2(S1,[],'Lc',[0 200 81],opt1); #! Faster and more accurate
# f_Lc = spec2tpdf(S1,[],'Lc',[0 200 81],[],NITa);
# pdfplot(f_Lc,'-.')
# wafostamp([],'(ER)')
# disp('Block = 22'), pause(pstate)
#
#
# f_Lc_1 = spec2tpdf(S1,[],'Lc',[0 200 81],1.5,NITa);
# #!f_Lc_1 = spec2tpdf2(S1,[],'Lc',[0 200 81],1.5,opt1);
#
# hold on
# pdfplot(f_Lc_1)
# wafostamp([],'(ER)')
#
# disp('Block = 23'), pause(pstate)
# #!#!
# clf
# simpson(f_Lc.x{1},f_Lc.f)
# simpson(f_Lc_1.x{1},f_Lc_1.f)
#
# disp('Block = 24'), pause(pstate)
# #!#!
# clf
# tic
#
# f_Lc_d1 = spec2tpdf(rotspec(SD1,pi/2),[],'Lc',[0 300 121],[],NITa);
# f_Lc_d12 = spec2tpdf(SD12,[],'Lc',[0 200 81],[],NITa);
# #! f_Lc_d1 = spec2tpdf2(rotspec(SD1,pi/2),[],'Lc',[0 300 121],opt1);
# #! f_Lc_d12 = spec2tpdf2(SD12,[],'Lc',[0 200 81],opt1);
# toc
# pdfplot(f_Lc_d1,'-.'), hold on
# pdfplot(f_Lc_d12), hold off
# wafostamp([],'(ER)')
#
# disp('Block = 25'), pause(pstate)
#
# #!#!
#
#
# clf
# opt1 = rindoptset('speed',5,'method',3);
# SD1r = rotspec(SD1,pi/2);
# if strncmpi(speed,'slow',1)
# f_Lc_d1_5 = spec2tpdf(SD1r,[], 'Lc',[0 300 121],[],5);
# pdfplot(f_Lc_d1_5), hold on
# else
# #! fast
# disp('Run the following example only if you want a check on computing time')
# disp('Edit the command file and remove #!')
# end
# f_Lc_d1_3 = spec2tpdf(SD1r,[],'Lc',[0 300 121],[],3);
# f_Lc_d1_2 = spec2tpdf(SD1r,[],'Lc',[0 300 121],[],2);
# f_Lc_d1_0 = spec2tpdf(SD1r,[],'Lc',[0 300 121],[],0);
# #!f_Lc_d1_n4 = spec2tpdf2(SD1r,[],'Lc',[0 400 161],opt1);
#
# pdfplot(f_Lc_d1_3), hold on
# pdfplot(f_Lc_d1_2)
# pdfplot(f_Lc_d1_0)
# #!pdfplot(f_Lc_d1_n4)
#
# #!simpson(f_Lc_d1_n4.x{1},f_Lc_d1_n4.f)
#
# disp('Block = 26'), pause(pstate)
#
# #!#! Section 3.4.2 Density of wave period, wave length or encountered wave period
# #!#! Example 7: Crest period and high crest waves
# clf
# tic
# xx = load('sea.dat');
# x = xx;
# x(:,2) = detrend(x(:,2));
# SS = dat2spec(x);
# si = sqrt(spec2mom(SS,1));
# SS.tr = dat2tr(x);
# Hs = 4*si
# method = 0;
# rate = 2;
# [S, H, Ac, At, Tcf, Tcb, z_ind, yn] = dat2steep(x,rate,method);
# Tc = Tcf+Tcb;
# t = linspace(0.01,8,200);
# ftc1 = kde(Tc,{'L2',0},t);
# pdfplot(ftc1)
# hold on
# #! f_t = spec2tpdf(SS,[],'Tc',[0 8 81],0,4);
# f_t = spec2tpdf(SS,[],'Tc',[0 8 81],0,2);
# simpson(f_t.x{1},f_t.f)
# pdfplot(f_t,'-.')
# hold off
# wafostamp([],'(ER)')
# toc
# disp('Block = 27'), pause(pstate)
#
# #!#!
# clf
# tic
#
# if strncmpi(speed,'slow',1)
# NIT = 4;
# else
# NIT = 2;
# end
# #! f_t2 = spec2tpdf(SS,[],'Tc',[0 8 81],[Hs/2],4);
# tic
# f_t2 = spec2tpdf(SS,[],'Tc',[0 8 81],Hs/2,NIT);
# toc
#
# Pemp = sum(Ac>Hs/2)/sum(Ac>0)
# simpson(f_t2.x{1},f_t2.f)
# index = find(Ac>Hs/2);
# ftc1 = kde(Tc(index),{'L2',0},t);
# ftc1.f = Pemp*ftc1.f;
# pdfplot(ftc1)
# hold on
# pdfplot(f_t2,'-.')
# hold off
# wafostamp([],'(ER)')
# toc
# disp('Block = 28'), pause(pstate)
#
# #!#! Example 8: Wave period for high crest waves
# #! clf
# tic
# f_tcc2 = spec2tccpdf(SS,[],'t>',[0 12 61],[Hs/2],[0],-1);
# toc
# simpson(f_tcc2.x{1},f_tcc2.f)
# f_tcc3 = spec2tccpdf(SS,[],'t>',[0 12 61],[Hs/2],[0],3,5);
# #! f_tcc3 = spec2tccpdf(SS,[],'t>',[0 12 61],[Hs/2],[0],1,5);
# simpson(f_tcc3.x{1},f_tcc3.f)
# pdfplot(f_tcc2,'-.')
# hold on
# pdfplot(f_tcc3)
# hold off
# toc
# disp('Block = 29'), pause(pstate)
#
# #!#!
# clf
# [TC tc_ind v_ind] = dat2tc(yn,[],'dw');
# N = length(tc_ind);
# t_ind = tc_ind(1:2:N);
# c_ind = tc_ind(2:2:N);
# Pemp = sum(yn(t_ind,2)<-Hs/2 & yn(c_ind,2)>Hs/2)/length(t_ind)
# ind = find(yn(t_ind,2)<-Hs/2 & yn(c_ind,2)>Hs/2);
# spwaveplot(yn,ind(2:4))
# wafostamp([],'(ER)')
# disp('Block = 30'), pause(pstate)
#
# #!#!
# clf
# Tcc = yn(v_ind(1+2*ind),1)-yn(v_ind(1+2*(ind-1)),1);
# t = linspace(0.01,14,200);
# ftcc1 = kde(Tcc,{'kernel' 'epan','L2',0},t);
# ftcc1.f = Pemp*ftcc1.f;
# pdfplot(ftcc1,'-.')
# wafostamp([],'(ER)')
# disp('Block = 31'), pause(pstate)
#
# tic
# f_tcc22_1 = spec2tccpdf(SS,[],'t>',[0 12 61],[Hs/2],[Hs/2],-1);
# toc
# simpson(f_tcc22_1.x{1},f_tcc22_1.f)
# hold on
# pdfplot(f_tcc22_1)
# hold off
# wafostamp([],'(ER)')
# disp('Block = 32'), pause(pstate)
#
# disp('The rest of this chapter deals with joint densities.')
# disp('Some calculations may take some time.')
# disp('You could experiment with other NIT.')
# #!return
#
# #!#! Section 3.4.3 Joint density of crest period and crest height
# #!#! Example 9. Some preliminary analysis of the data
# clf
# tic
# yy = load('gfaksr89.dat');
# SS = dat2spec(yy);
# si = sqrt(spec2mom(SS,1));
# SS.tr = dat2tr(yy);
# Hs = 4*si
# v = gaus2dat([0 0],SS.tr);
# v = v(2)
# toc
# disp('Block = 33'), pause(pstate)
#
# #!#!
# clf
# tic
# [TC, tc_ind, v_ind] = dat2tc(yy,v,'dw');
# N = length(tc_ind);
# t_ind = tc_ind(1:2:N);
# c_ind = tc_ind(2:2:N);
# v_ind_d = v_ind(1:2:N+1);
# v_ind_u = v_ind(2:2:N+1);
# T_d = ecross(yy(:,1),yy(:,2),v_ind_d,v);
# T_u = ecross(yy(:,1),yy(:,2),v_ind_u,v);
#
# Tc = T_d(2:end)-T_u(1:end);
# Tt = T_u(1:end)-T_d(1:end-1);
# Tcf = yy(c_ind,1)-T_u;
# Ac = yy(c_ind,2)-v;
# At = v-yy(t_ind,2);
# toc
# disp('Block = 34'), pause(pstate)
#
# #!#!
# clf
# tic
# t = linspace(0.01,15,200);
# kopt3 = kdeoptset('hs',0.25,'L2',0);
# ftc1 = kde(Tc,kopt3,t);
# ftt1 = kde(Tt,kopt3,t);
# pdfplot(ftt1,'k')
# hold on
# pdfplot(ftc1,'k-.')
# f_tc4 = spec2tpdf(SS,[],'Tc',[0 12 81],0,4,5);
# f_tc2 = spec2tpdf(SS,[],'Tc',[0 12 81],0,2,5);
# f_tc = spec2tpdf(SS,[],'Tc',[0 12 81],0,-1);
# pdfplot(f_tc,'b')
# hold off
# legend('kde(Tt)','kde(Tc)','f_{tc}')
# wafostamp([],'(ER)')
# toc
# disp('Block = 35'), pause(pstate)
#
# #!#! Example 10: Joint characteristics of a half wave:
# #!#! position and height of a crest for a wave with given period
# clf
# tic
# ind = find(4.4<Tc & Tc<4.6);
# f_AcTcf = kde([Tcf(ind) Ac(ind)],{'L2',[1 .5]});
# pdfplot(f_AcTcf)
# hold on
# plot(Tcf(ind), Ac(ind),'.');
# wafostamp([],'(ER)')
# toc
# disp('Block = 36'), pause(pstate)
#
# #!#!
# clf
# tic
# opt1 = rindoptset('speed',5,'method',3);
# opt2 = rindoptset('speed',5,'nit',2,'method',0);
#
# f_tcfac1 = spec2thpdf(SS,[],'TcfAc',[4.5 4.5 46],[0:0.25:8],opt1);
# f_tcfac2 = spec2thpdf(SS,[],'TcfAc',[4.5 4.5 46],[0:0.25:8],opt2);
#
# pdfplot(f_tcfac1,'-.')
# hold on
# pdfplot(f_tcfac2)
# plot(Tcf(ind), Ac(ind),'.');
#
# simpson(f_tcfac1.x{1},simpson(f_tcfac1.x{2},f_tcfac1.f,1))
# simpson(f_tcfac2.x{1},simpson(f_tcfac2.x{2},f_tcfac2.f,1))
# f_tcf4=spec2tpdf(SS,[],'Tc',[4.5 4.5 46],[0:0.25:8],6);
# f_tcf4.f(46)
# toc
# wafostamp([],'(ER)')
# disp('Block = 37'), pause(pstate)
#
# #!#!
# clf
# f_tcac_s = spec2thpdf(SS,[],'TcAc',[0 12 81],[Hs/2:0.1:2*Hs],opt1);
# disp('Block = 38'), pause(pstate)
#
# clf
# tic
# mom = spec2mom(SS,4,[],0);
# t = f_tcac_s.x{1};
# h = f_tcac_s.x{2};
# flh_g = lh83pdf(t',h',[mom(1),mom(2),mom(3)],SS.tr);
# clf
# ind=find(Ac>Hs/2);
# plot(Tc(ind), Ac(ind),'.');
# hold on
# pdfplot(flh_g,'k-.')
# pdfplot(f_tcac_s)
# toc
# wafostamp([],'(ER)')
# disp('Block = 39'), pause(pstate)
#
# #!#!
# clf
# #! f_tcac = spec2thpdf(SS,[],'TcAc',[0 12 81],[0:0.2:8],opt1);
# #! pdfplot(f_tcac)
# disp('Block = 40'), pause(pstate)
#
# #!#! Section 3.4.4 Joint density of crest and trough height
# #!#! Section 3.4.5 Min-to-max distributions Markov method
# #!#! Example 11. (min-max problems with Gullfaks data)
# #!#! Joint density of maximum and the following minimum
# clf
# tic
# tp = dat2tp(yy);
# Mm = fliplr(tp2mm(tp));
# fmm = kde(Mm);
# f_mM = spec2mmtpdf(SS,[],'mm',[],[-7 7 51],opt2);
#
# pdfplot(f_mM,'-.')
# hold on
# pdfplot(fmm,'k-')
# hold off
# wafostamp([],'(ER)')
# toc
# disp('Block = 41'), pause(pstate)
#
# #!#! The joint density of still water separated maxima and minima.
# clf
# tic
# ind = find(Mm(:,1)>v & Mm(:,2)<v);
# Mmv = abs(Mm(ind,:)-v);
# fmmv = kde(Mmv);
# f_vmm = spec2mmtpdf(SS,[],'vmm',[],[-7 7 51],opt2);
# clf
# pdfplot(fmmv,'k-')
# hold on
# pdfplot(f_vmm,'-.')
# hold off
# wafostamp([],'(ER)')
# toc
# disp('Block = 42'), pause(pstate)
#
#
# #!#!
# clf
# tic
# facat = kde([Ac At]);
# f_acat = spec2mmtpdf(SS,[],'AcAt',[],[-7 7 51],opt2);
# clf
# pdfplot(f_acat,'-.')
# hold on
# pdfplot(facat,'k-')
# hold off
# wafostamp([],'(ER)')
# toc
# disp('Block = 43'), pause(pstate)

@ -1,407 +0,0 @@
#! CHAPTER4 contains the commands used in Chapter 4 of the tutorial
#!=================================================================
#!
#! CALL: Chapter4
#!
#! Some of the commands are edited for fast computation.
#! Each set of commands is followed by a 'pause' command.
#!
#! This routine also can print the figures;
#! For printing the figures on directory ../bilder/ edit the file and put
#! printing=1;
#! Tested on Matlab 5.3
#! History
#! Revised pab sept2005
#! Added sections -> easier to evaluate using cellmode evaluation.
#! revised pab Feb2004
#! updated call to lc2sdat
#! Created by GL July 13, 2000
#! from commands used in Chapter 4
#!
#! Chapter 4 Fatigue load analysis and rain-flow cycles
#!------------------------------------------------------
printing = 0
#! Section 4.3.1 Crossing intensity
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import numpy as np
from wafo.plotbackend import plotbackend as plt
import wafo.data as wd
import wafo.objects as wo
xx_sea = wd.sea()
ts = wo.mat2timeseries(xx_sea)
tp = ts.turning_points()
mM = tp.cycle_pairs(kind='min2max')
lc = mM.level_crossings(intensity=True)
T_sea = ts.args[-1]-ts.args[0]
plt.subplot(1,2,1)
lc.plot()
plt.subplot(1,2,2)
lc.setplotter(plotmethod='step')
lc.plot()
plt.show()
m_sea = ts.data.mean()
f0_sea = np.interp(m_sea, lc.args,lc.data)
extr_sea = len(tp.data)/(2*T_sea)
alfa_sea = f0_sea/extr_sea
print('alfa = %g ' % alfa_sea)
#! Section 4.3.2 Extraction of rainflow cycles
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Min-max and rainflow cycle plots
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mM_rfc = tp.cycle_pairs(h=0.3)
plt.clf()
plt.subplot(122),
mM.plot()
plt.title('min-max cycle pairs')
plt.subplot(121),
mM_rfc.plot()
plt.title('Rainflow filtered cycles')
plt.show()
#! Min-max and rainflow cycle distributions
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.misc as wm
ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
plt.clf()
plt.subplot(121)
wm.plot_histgrm(ampmM_sea,25)
ylim = plt.gca().get_ylim()
plt.title('min-max amplitude distribution')
plt.subplot(122)
wm.plot_histgrm(ampRFC_sea,25)
plt.gca().set_ylim(ylim)
plt.title('Rainflow amplitude distribution')
plt.show()
#!#! Section 4.3.3 Simulation of rainflow cycles
#!#! Simulation of cycles in a Markov model
# n = 41
# param_m = [-1, 1, n]
# param_D = [1, n, n]
# u_markov=levels(param_m);
# G_markov=mktestmat(param_m,[-0.2, 0.2],0.15,1);
# T_markov=5000;
#xxD_markov=mctpsim({G_markov [,]},T_markov);
#xx_markov=[(1:T_markov)' u_markov(xxD_markov)'];
#clf
#plot(xx_markov(1:50,1),xx_markov(1:50,2))
#title('Markov chain of turning points')
#wafostamp([],'(ER)')
#disp('Block 5'),pause(pstate)
#
#
##!#! Rainflow cycles in a transformed Gaussian model
##!#! Hermite transformed wave data and rainflow filtered turning points, h = 0.2.
#me = mean(xx_sea(:,2));
#sa = std(xx_sea(:,2));
#Hm0_sea = 4*sa;
#Tp_sea = 1/max(lc_sea(:,2));
#spec = jonswap([],[Hm0_sea Tp_sea]);
#
#[sk, ku] = spec2skew(spec);
#spec.tr = hermitetr([],[sa sk ku me]);
#param_h = [-1.5 2 51];
#spec_norm = spec;
#spec_norm.S = spec_norm.S/sa^2;
#xx_herm = spec2sdat(spec_norm,[2^15 1],0.1);
##! ????? PJ, JR 11-Apr-2001
##! NOTE, in the simulation program spec2sdat
##!the spectrum must be normalized to variance 1
##! ?????
#h = 0.2;
#[dtp,u_herm,xx_herm_1]=dat2dtp(param_h,xx_herm,h);
#clf
#plot(xx_herm(:,1),xx_herm(:,2),'k','LineWidth',2); hold on;
#plot(xx_herm_1(:,1),xx_herm_1(:,2),'k--','Linewidth',2);
#axis([0 50 -1 1]), hold off;
#title('Rainflow filtered wave data')
#wafostamp([],'(ER)')
#disp('Block 6'),pause(pstate)
#
##!#! Rainflow cycles and rainflow filtered rainflow cycles in the transformed Gaussian process.
#tp_herm=dat2tp(xx_herm);
#RFC_herm=tp2rfc(tp_herm);
#mM_herm=tp2mm(tp_herm);
#h=0.2;
#[dtp,u,tp_herm_1]=dat2dtp(param_h,xx_herm,h);
#RFC_herm_1 = tp2rfc(tp_herm_1);
#clf
#subplot(121), ccplot(RFC_herm)
#title('h=0')
#subplot(122), ccplot(RFC_herm_1)
#title('h=0.2')
#if (printing==1), print -deps ../bilder/fatigue_8.eps
#end
#wafostamp([],'(ER)')
#disp('Block 7'),pause(pstate)
#
##!#! Section 4.3.4 Calculating the rainflow matrix
#
#
#Grfc_markov=mctp2rfm({G_markov []});
#clf
#subplot(121), cmatplot(u_markov,u_markov,G_markov), axis('square')
#subplot(122), cmatplot(u_markov,u_markov,Grfc_markov), axis('square')
#wafostamp([],'(ER)')
#disp('Block 8'),pause(pstate)
#
##!#!
#clf
#cmatplot(u_markov,u_markov,{G_markov Grfc_markov},3)
#wafostamp([],'(ER)')
#disp('Block 9'),pause(pstate)
#
##!#! Min-max-matrix and theoretical rainflow matrix for test Markov sequence.
#cmatplot(u_markov,u_markov,{G_markov Grfc_markov},4)
#subplot(121), axis('square'), title('min2max transition matrix')
#subplot(122), axis('square'), title('Rainflow matrix')
#if (printing==1), print -deps ../bilder/fatigue_9.eps
#end
#wafostamp([],'(ER)')
#disp('Block 10'),pause(pstate)
#
##!#! Observed and theoretical rainflow matrix for test Markov sequence.
#n=length(u_markov);
#Frfc_markov=dtp2rfm(xxD_markov,n);
#clf
#cmatplot(u_markov,u_markov,{Frfc_markov Grfc_markov*T_markov/2},3)
#subplot(121), axis('square'), title('Observed rainflow matrix')
#subplot(122), axis('square'), title('Theoretical rainflow matrix')
#if (printing==1), print -deps ../bilder/fatigue_10.eps
#end
#wafostamp([],'(ER)')
#disp('Block 11'),pause(pstate)
#
##!#! Smoothed observed and calculated rainflow matrix for test Markov sequence.
#tp_markov=dat2tp(xx_markov);
#RFC_markov=tp2rfc(tp_markov);
#h=1;
#Frfc_markov_smooth=cc2cmat(param_m,RFC_markov,[],1,h);
#clf
#cmatplot(u_markov,u_markov,{Frfc_markov_smooth Grfc_markov*T_markov/2},4)
#subplot(121), axis('square'), title('Smoothed observed rainflow matrix')
#subplot(122), axis('square'), title('Theoretical rainflow matrix')
#if (printing==1), print -deps ../bilder/fatigue_11.eps
#end
#wafostamp([],'(ER)')
#disp('Block 12'),pause(pstate)
#
##!#! Rainflow matrix from spectrum
#clf
##!GmM3_herm=spec2mmtpdf(spec,[],'Mm',[],[],2);
#GmM3_herm=spec2cmat(spec,[],'Mm',[],param_h,2);
#pdfplot(GmM3_herm)
#wafostamp([],'(ER)')
#disp('Block 13'),pause(pstate)
#
#
##!#! Min-max matrix and theoretical rainflow matrix for Hermite-transformed Gaussian waves.
#Grfc_herm=mctp2rfm({GmM3_herm.f []});
#u_herm=levels(param_h);
#clf
#cmatplot(u_herm,u_herm,{GmM3_herm.f Grfc_herm},4)
#subplot(121), axis('square'), title('min-max matrix')
#subplot(122), axis('square'), title('Theoretical rainflow matrix')
#if (printing==1), print -deps ../bilder/fatigue_12.eps
#end
#wafostamp([],'(ER)')
#disp('Block 14'),pause(pstate)
#
##!#!
#clf
#Grfc_direct_herm=spec2cmat(spec,[],'rfc',[],[],2);
#subplot(121), pdfplot(GmM3_herm), axis('square'), hold on
#subplot(122), pdfplot(Grfc_direct_herm), axis('square'), hold off
#if (printing==1), print -deps ../bilder/fig_mmrfcjfr.eps
#end
#wafostamp([],'(ER)')
#disp('Block 15'),pause(pstate)
#
#
##!#! Observed smoothed and theoretical min-max matrix,
##!#! (and observed smoothed and theoretical rainflow matrix for Hermite-transformed Gaussian waves).
#tp_herm=dat2tp(xx_herm);
#RFC_herm=tp2rfc(tp_herm);
#mM_herm=tp2mm(tp_herm);
#h=0.2;
#FmM_herm_smooth=cc2cmat(param_h,mM_herm,[],1,h);
#Frfc_herm_smooth=cc2cmat(param_h,RFC_herm,[],1,h);
#T_herm=xx_herm(end,1)-xx_herm(1,1);
#clf
#cmatplot(u_herm,u_herm,{FmM_herm_smooth GmM3_herm.f*length(mM_herm) ; ...
# Frfc_herm_smooth Grfc_herm*length(RFC_herm)},4)
#subplot(221), axis('square'), title('Observed smoothed min-max matrix')
#subplot(222), axis('square'), title('Theoretical min-max matrix')
#subplot(223), axis('square'), title('Observed smoothed rainflow matrix')
#subplot(224), axis('square'), title('Theoretical rainflow matrix')
#if (printing==1), print -deps ../bilder/fatigue_13.eps
#end
#wafostamp([],'(ER)')
#disp('Block 16'),pause(pstate)
#
##!#! Section 4.3.5 Simulation from crossings and rainflow structure
#
##!#! Crossing spectrum (smooth curve) and obtained spectrum (wiggled curve)
##!#! for simulated process with irregularity factor 0.25.
#clf
#cross_herm=dat2lc(xx_herm);
#alpha1=0.25;
#alpha2=0.75;
#xx_herm_sim1=lc2sdat(cross_herm,500,alpha1);
#cross_herm_sim1=dat2lc(xx_herm_sim1);
#subplot(211)
#plot(cross_herm(:,1),cross_herm(:,2)/max(cross_herm(:,2)))
#hold on
#stairs(cross_herm_sim1(:,1),...
# cross_herm_sim1(:,2)/max(cross_herm_sim1(:,2)))
#hold off
#title('Crossing intensity, \alpha = 0.25')
#subplot(212)
#plot(xx_herm_sim1(:,1),xx_herm_sim1(:,2))
#title('Simulated load, \alpha = 0.25')
#if (printing==1), print -deps ../bilder/fatigue_14_25.eps
#end
#wafostamp([],'(ER)')
#disp('Block 16'),pause(pstate)
#
##!#! Crossing spectrum (smooth curve) and obtained spectrum (wiggled curve)
##!#! for simulated process with irregularity factor 0.75.
#xx_herm_sim2=lc2sdat(cross_herm,500,alpha2);
#cross_herm_sim2=dat2lc(xx_herm_sim2);
#subplot(211)
#plot(cross_herm(:,1),cross_herm(:,2)/max(cross_herm(:,2)))
#hold on
#stairs(cross_herm_sim2(:,1),...
# cross_herm_sim2(:,2)/max(cross_herm_sim2(:,2)))
#hold off
#title('Crossing intensity, \alpha = 0.75')
#subplot(212)
#plot(xx_herm_sim2(:,1),xx_herm_sim2(:,2))
#title('Simulated load, \alpha = 0.75')
#if (printing==1), print -deps ../bilder/fatigue_14_75.eps
#end
#wafostamp([],'(ER)')
#disp('Block 17'),pause(pstate)
#
##!#! Section 4.4 Fatigue damage and fatigue life distribution
##!#! Section 4.4.1 Introduction
#beta=3.2; gam=5.5E-10; T_sea=xx_sea(end,1)-xx_sea(1,1);
#d_beta=cc2dam(RFC_sea,beta)/T_sea;
#time_fail=1/gam/d_beta/3600 #!in hours of the specific storm
#disp('Block 18'),pause(pstate)
#
##!#! Section 4.4.2 Level crossings
##!#! Crossing intensity as calculated from the Markov matrix (solid curve) and from the observed rainflow matrix (dashed curve).
#clf
#mu_markov=cmat2lc(param_m,Grfc_markov);
#muObs_markov=cmat2lc(param_m,Frfc_markov/(T_markov/2));
#clf
#plot(mu_markov(:,1),mu_markov(:,2),muObs_markov(:,1),muObs_markov(:,2),'--')
#title('Theoretical and observed crossing intensity ')
#if (printing==1), print -deps ../bilder/fatigue_15.eps
#end
#wafostamp([],'(ER)')
#disp('Block 19'),pause(pstate)
#
##!#! Section 4.4.3 Damage
##!#! Distribution of damage from different RFC cycles, from calculated theoretical and from observed rainflow matrix.
#beta = 4;
#Dam_markov = cmat2dam(param_m,Grfc_markov,beta)
#DamObs1_markov = cc2dam(RFC_markov,beta)/(T_markov/2)
#DamObs2_markov = cmat2dam(param_m,Frfc_markov,beta)/(T_markov/2)
#disp('Block 20'),pause(pstate)
#
#Dmat_markov = cmat2dmat(param_m,Grfc_markov,beta);
#DmatObs_markov = cmat2dmat(param_m,Frfc_markov,beta)/(T_markov/2);
#clf
#subplot(121), cmatplot(u_markov,u_markov,Dmat_markov,4)
#title('Theoretical damage matrix')
#subplot(122), cmatplot(u_markov,u_markov,DmatObs_markov,4)
#title('Observed damage matrix')
#if (printing==1), print -deps ../bilder/fatigue_16.eps
#end
#wafostamp([],'(ER)')
#disp('Block 21'),pause(pstate)
#
#
##!#!
##!Damplus_markov = lc2dplus(mu_markov,beta)
#pause(pstate)
#
##!#! Section 4.4.4 Estimation of S-N curve
#
##!#! Load SN-data and plot in log-log scale.
#SN = load('sn.dat');
#s = SN(:,1);
#N = SN(:,2);
#clf
#loglog(N,s,'o'), axis([0 14e5 10 30])
##!if (printing==1), print -deps ../bilder/fatigue_?.eps end
#wafostamp([],'(ER)')
#disp('Block 22'),pause(pstate)
#
#
##!#! Check of S-N-model on normal probability paper.
#
#normplot(reshape(log(N),8,5))
#if (printing==1), print -deps ../bilder/fatigue_17.eps
#end
#wafostamp([],'(ER)')
#disp('Block 23'),pause(pstate)
#
##!#! Estimation of S-N-model on linear scale.
#clf
#[e0,beta0,s20] = snplot(s,N,12);
#title('S-N-data with estimated N(s)','FontSize',20)
#set(gca,'FontSize',20)
#if (printing==1), print -deps ../bilder/fatigue_18a.eps
#end
#wafostamp([],'(ER)')
#disp('Block 24'),pause(pstate)
#
##!#! Estimation of S-N-model on log-log scale.
#clf
#[e0,beta0,s20] = snplot(s,N,14);
#title('S-N-data with estimated N(s)','FontSize',20)
#set(gca,'FontSize',20)
#if (printing==1), print -deps ../bilder/fatigue_18b.eps
#end
#wafostamp([],'(ER)')
#disp('Block 25'),pause(pstate)
#
##!#! Section 4.4.5 From S-N curve to fatigue life distribution
##!#! Damage intensity as function of $\beta$
#beta = 3:0.1:8;
#DRFC = cc2dam(RFC_sea,beta);
#dRFC = DRFC/T_sea;
#plot(beta,dRFC), axis([3 8 0 0.25])
#title('Damage intensity as function of \beta')
#if (printing==1), print -deps ../bilder/fatigue_19.eps
#end
#wafostamp([],'(ER)')
#disp('Block 26'),pause(pstate)
#
##!#! Fatigue life distribution with sea load.
#dam0 = cc2dam(RFC_sea,beta0)/T_sea;
#[t0,F0] = ftf(e0,dam0,s20,0.5,1);
#[t1,F1] = ftf(e0,dam0,s20,0,1);
#[t2,F2] = ftf(e0,dam0,s20,5,1);
#plot(t0,F0,t1,F1,t2,F2)
#title('Fatigue life distribution function')
#if (printing==1), print -deps ../bilder/fatigue_20.eps
#end
#wafostamp([],'(ER)')
#disp('Block 27, last block')

@ -1,238 +0,0 @@
## CHAPTER5 contains the commands used in Chapter 5 of the tutorial
#
# CALL: Chapter5
#
# Some of the commands are edited for fast computation.
# Each set of commands is followed by a 'pause' command.
#
# Tested on Matlab 5.3
# History
# Added Return values by GL August 2008
# Revised pab sept2005
# Added sections -> easier to evaluate using cellmode evaluation.
# Created by GL July 13, 2000
# from commands used in Chapter 5
#
## Chapter 5 Extreme value analysis
## Section 5.1 Weibull and Gumbel papers
from __future__ import division
import numpy as np
import scipy.interpolate as si
from wafo.plotbackend import plotbackend as plt
import wafo.data as wd
import wafo.objects as wo
import wafo.stats as ws
import wafo.kdetools as wk
pstate = 'off'
# Significant wave-height data on Weibull paper,
fig = plt.figure()
ax = fig.add_subplot(111)
Hs = wd.atlantic()
wei = ws.weibull_min.fit(Hs)
tmp = ws.probplot(Hs, wei, ws.weibull_min, plot=ax)
plt.show()
#wafostamp([],'(ER)')
#disp('Block = 1'),pause(pstate)
##
# Significant wave-height data on Gumbel paper,
plt.clf()
ax = fig.add_subplot(111)
gum = ws.gumbel_r.fit(Hs)
tmp1 = ws.probplot(Hs, gum, ws.gumbel_r, plot=ax)
#wafostamp([],'(ER)')
plt.show()
#disp('Block = 2'),pause(pstate)
##
# Significant wave-height data on Normal probability paper,
plt.clf()
ax = fig.add_subplot(111)
phat = ws.norm.fit2(np.log(Hs))
phat.plotresq()
#tmp2 = ws.probplot(np.log(Hs), phat, ws.norm, plot=ax)
#wafostamp([],'(ER)')
plt.show()
#disp('Block = 3'),pause(pstate)
##
# Return values in the Gumbel distribution
plt.clf()
T = np.r_[1:100000]
sT = gum[0] - gum[1] * np.log(-np.log1p(-1./T))
plt.semilogx(T, sT)
plt.hold(True)
# ws.edf(Hs).plot()
Nmax = len(Hs)
N = np.r_[1:Nmax + 1]
plt.plot(Nmax/N, sorted(Hs, reverse=True), '.')
plt.title('Return values in the Gumbel model')
plt.xlabel('Return period')
plt.ylabel('Return value')
#wafostamp([],'(ER)')
plt.show()
#disp('Block = 4'),pause(pstate)
## Section 5.2 Generalized Pareto and Extreme Value distributions
## Section 5.2.1 Generalized Extreme Value distribution
# Empirical distribution of significant wave-height with estimated
# Generalized Extreme Value distribution,
gev = ws.genextreme.fit2(Hs)
gev.plotfitsummary()
# wafostamp([],'(ER)')
# disp('Block = 5a'),pause(pstate)
plt.clf()
x = np.linspace(0,14,200)
kde = wk.TKDE(Hs, L2=0.5)(x, output='plot')
kde.plot()
plt.hold(True)
plt.plot(x, gev.pdf(x),'--')
# disp('Block = 5b'),pause(pstate)
# Analysis of yura87 wave data.
# Wave data interpolated (spline) and organized in 5-minute intervals
# Normalized to mean 0 and std = 1 to get stationary conditions.
# maximum level over each 5-minute interval analysed by GEV
xn = wd.yura87()
XI = np.r_[1:len(xn):0.25] - .99
N = len(XI)
N = N - np.mod(N, 4*60*5)
YI = si.interp1d(xn[:, 0], xn[:, 1], kind='linear')(XI)
YI = YI.reshape(4*60*5, N/(4*60*5)) # Each column holds 5 minutes of
# interpolated data.
Y5 = (YI - YI.mean(axis=0)) / YI.std(axis=0)
Y5M = Y5.maximum(axis=0)
Y5gev = ws.genextreme.fit2(Y5M,method='mps')
Y5gev.plotfitsummary()
#wafostamp([],'(ER)')
#disp('Block = 6'),pause(pstate)
## Section 5.2.2 Generalized Pareto distribution
# Exceedances of significant wave-height data over level 3,
gpd3 = ws.genpareto.fit2(Hs[Hs>3]-3, floc=0)
gpd3.plotfitsummary()
#wafostamp([],'(ER)')
##
plt.figure()
# Exceedances of significant wave-height data over level 7,
gpd7 = ws.genpareto.fit2(Hs(Hs>7), floc=7)
gpd7.plotfitsummary()
# wafostamp([],'(ER)')
# disp('Block = 6'),pause(pstate)
##
#Simulates 100 values from the GEV distribution with parameters (0.3, 1, 2),
# then estimates the parameters using two different methods and plots the
# estimated distribution functions together with the empirical distribution.
Rgev = ws.genextreme.rvs(0.3,1,2,size=100)
gp = ws.genextreme.fit2(Rgev, method='mps');
gm = ws.genextreme.fit2(Rgev, *gp.par.tolist(), method='ml')
gm.plotfitsummary()
gp.plotecdf()
plt.hold(True)
plt.plot(x, gm.cdf(x), '--')
plt.hold(False)
#wafostamp([],'(ER)')
#disp('Block =7'),pause(pstate)
##
# ;
Rgpd = ws.genpareto.rvs(0.4,0, 1,size=100)
gp = ws.genpareto.fit2(Rgpd, method='mps')
gml = ws.genpareto.fit2(Rgpd, method='ml')
gp.plotecdf()
x = sorted(Rgpd)
plt.hold(True)
plt.plot(x, gml.cdf(x))
# gm = fitgenpar(Rgpd,'method','mom','plotflag',0);
# plot(x,cdfgenpar(x,gm),'g--')
#gw = fitgenpar(Rgpd,'method','pwm','plotflag',0);
#plot(x,cdfgenpar(x,gw),'g:')
#gml = fitgenpar(Rgpd,'method','ml','plotflag',0);
#plot(x,cdfgenpar(x,gml),'--')
#gmps = fitgenpar(Rgpd,'method','mps','plotflag',0);
#plot(x,cdfgenpar(x,gmps),'r-.')
plt.hold(False)
#wafostamp([],'(ER)')
#disp('Block = 8'),pause(pstate)
##
# Return values for the GEV distribution
T = np.logspace(1, 5, 10);
#[sT, sTlo, sTup] = invgev(1./T,Y5gev,'lowertail',false,'proflog',true);
#T = 2:100000;
#k=Y5gev.params(1); mu=Y5gev.params(3); sigma=Y5gev.params(2);
#sT1 = invgev(1./T,Y5gev,'lowertail',false);
#sT=mu + sigma/k*(1-(-log(1-1./T)).^k);
plt.clf()
#plt.semilogx(T,sT,T,sTlo,'r',T,sTup,'r')
#plt.hold(True)
#N = np.r_[1:len(Y5M)]
#Nmax = max(N);
#plot(Nmax./N, sorted(Y5M,reverse=True), '.')
#plt.title('Return values in the GEV model')
#plt.xlabel('Return priod')
#plt.ylabel('Return value')
#plt.grid(True)
#disp('Block = 9'),pause(pstate)
## Section 5.3 POT-analysis
# Estimated expected exceedance over level u as function of u.
plt.clf()
mrl = ws.reslife(Hs,'umin',2,'umax',10,'Nu',200);
mrl.plot()
#wafostamp([],'(ER)')
#disp('Block = 10'),pause(pstate)
##
# Estimated distribution functions of monthly maxima
#with the POT method (solid),
# fitting a GEV (dashed) and the empirical distribution.
# POT- method
gpd7 = ws.genpareto.fit2(Hs(Hs>7)-7, method='mps', floc=0)
khat, loc, sigmahat = gpd7.par
muhat = len(Hs[Hs>7])/(7*3*2)
bhat = sigmahat/muhat**khat
ahat = 7-(bhat-sigmahat)/khat
x = np.linspace(5,15,200);
plt.plot(x,ws.genextreme.cdf(x, khat,bhat,ahat))
# disp('Block = 11'),pause(pstate)
##
# Since we have data to compute the monthly maxima mm over
#42 months we can also try to fit a
# GEV distribution directly:
mm = np.zeros((1,41))
for i in range(41):
mm[i] = max(Hs[((i-1)*14+1):i*14])
gev = ws.genextreme.fit2(mm)
plt.hold(True)
gev.plotecdf()
plt.hold(False)
#wafostamp([],'(ER)')
#disp('Block = 12, Last block'),pause(pstate)

@ -1,176 +0,0 @@
from tutor_init import *
import itertools
# import sys
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
MARKERS = ('o', 'x', '+', '.', '<', '>', '^', 'v')
def plot_varying_symbols(x, y, color='red', size=5):
"""
Create a plot with varying symbols
Parameters
----------
x : numpy array with x data of the points
y : numpy array with y data of the points
color : color of the symbols
Returns
-------
"""
markers = itertools.cycle(MARKERS)
for q, p in zip(x, y):
plt.plot(q, p, marker=markers.next(), linestyle='', color=color,
markersize=size)
def damage_vs_S(S, beta, K):
"""
Calculate the damage 1/N for a given stress S
Parameters
----------
S : Stress [Pa]
beta : coefficient, typically 3
K : constant
Returns
-------
"""
return K * np.power(S, beta)
# Section 4.3.1 Crossing intensity
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.data as wd
import wafo.objects as wo
import wafo.misc as wm
xx_sea = wd.sea()
Tlength = xx_sea[-1, 0] - xx_sea[0, 0]
beta = 3
K1 = 6.5e-31
Np = 200
Tp = Tlength / Np
A = 100e6
log.info("setting sin wave with Tp={} and T={}".format(Tp, Tlength))
Nc = 1.0 / damage_vs_S(A, beta, K1)
damage = float(Np) / float(Nc)
log.info("budget at S={} N={}: damage = {} ".format(A, Nc, damage))
#xx_sea[:, 1] = A * np.cos(2 * np.pi * xx_sea[:, 0]/Tp)
xx_sea[:, 1] *= 500e6
log.info("loaded sea time series {}".format(xx_sea.shape))
ts = wo.mat2timeseries(xx_sea)
tp = ts.turning_points()
mM = tp.cycle_pairs(kind='min2max')
Mm = tp.cycle_pairs(kind='max2min')
lc = mM.level_crossings(intensity=True)
T_sea = ts.args[-1] - ts.args[0]
# for i in dir(mM):
# print(i)
ts1 = wo.mat2timeseries(xx_sea[:, :])
tp1 = ts1.turning_points()
sig_tp = ts.turning_points(h=0, wavetype='astm')
try:
sig_cp = sig_tp.cycle_astm()
log.info("Successfully used cycle_astm")
except AttributeError:
log.warning("Could use cycle_astm")
sig_cp = None
tp1 = ts1.turning_points()
tp2 = ts1.turning_points(wavetype='Mw')
mM1 = tp1.cycle_pairs(kind='min2max')
Mm1 = tp1.cycle_pairs(kind='max2min')
tp_rfc = tp1.rainflow_filter(h=100e6)
mM_rfc = tp_rfc.cycle_pairs()
try:
mM_rfc_a = tp1.cycle_astm()
except AttributeError:
mM_rfc_a = None
tc1 = ts1.trough_crest()
min_to_max = True
rfc_plot = True
if min_to_max:
m1, M1 = mM1.get_minima_and_maxima()
i_min_start = 0
else:
m1, M1 = Mm1.get_minima_and_maxima()
i_min_start = 2
m_rfc, M_rfc = mM_rfc.get_minima_and_maxima()
# m_rfc_a, M_rfc_a = mM_rfc_a.get_minima_and_maxima()
ts1.plot('b-')
if rfc_plot:
plot_varying_symbols(tp_rfc.args[0::2], m_rfc, color='red', size=10)
plot_varying_symbols(tp_rfc.args[1::2], M_rfc, color='green', size=10)
else:
plot_varying_symbols(tp.args[i_min_start::2], m1, color='red', size=10)
plot_varying_symbols(tp.args[1::2], M1, color='green', size=10)
set_windows_title("Sea time series", log)
plt.figure()
plt.subplot(122),
mM.plot()
plt.title('min-max cycle pairs')
plt.subplot(121),
mM_rfc.plot()
title = 'Rainflow filtered cycles'
plt.title(title)
set_windows_title(title)
# Min-max and rainflow cycle distributions
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# import wafo.misc as wm
ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
plt.figure()
title = "s_n_curve"
set_windows_title(title)
S = np.linspace(1e6, 1000e6)
plt.loglog(S, damage_vs_S(S, beta, K1))
plt.figure()
plt.subplot(121)
stress_range = (1, 1e9)
n_bins = 100
wm.plot_histgrm(ampmM_sea, bins=n_bins, range=stress_range)
plt.xlim(stress_range)
ylim = plt.gca().get_ylim()
plt.title('min-max amplitude distribution')
plt.subplot(122)
if sig_cp is not None:
wm.plot_histgrm(sig_cp[:, 0], bins=n_bins, range=stress_range)
plt.gca().set_ylim(ylim)
title = 'Rainflow amplitude distribution'
plt.title(title)
plt.semilogy
set_windows_title(title)
hist, bin_edges = np.histogram(
sig_cp[
:, 0], bins=n_bins, range=stress_range)
plt.figure()
title = "my_bins"
plt.title(title)
plt.title(title)
set_windows_title(title)
plt.semilogy
plt.bar(bin_edges[:-1], hist, width=stress_range[1] / n_bins)
print("damage min/max : {}".format(mM_rfc.damage([beta], K1)))
damage_rfc = K1 * np.sum(sig_cp[:, 0] ** beta)
print("damage rfc : {}".format(damage_rfc))
plt.show('hold')

@ -1,27 +0,0 @@
import logging
import scipy as sp
import numpy as np
from numpy import pi, reshape
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Qt4Agg')
from matplotlib import rcParams
rcParams.update({"font.size": 10})
try:
from win32api import LoadResource
except ImportError:
pass
log = logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.DEBUG)
def set_windows_title(title, log=None):
if log is not None:
log.info("Set windows title {}".format(title))
fig = plt.gcf()
fig.canvas.set_window_title(title)
plt.show()

@ -1,65 +0,0 @@
# -*- coding: utf-8 -*-
"""
f2py c_library.pyf c_functions.c -c
See also http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW
"""
import os
import sys
def which(program):
"""
Return filepath to program if it exists
In order to test if a certain executable exists, it will search for the
program name in the environment variables.
If program is a full path to an executable, it will check it exists
Copied from:
http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/
It is supposed to mimic the UNIX command "which"
"""
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
fpath, unused_fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def f2py_call_str():
'''Return which f2py callable is in the path regardless of platform'''
# define possible options:
# on Arch Linux, python and f2py are the calls corresponding to python 3
# and python2/f2py2 for python 2
# other Linux versions might still use python/f2py for python 2
if os.path.basename(sys.executable).endswith('2'):
options = ('f2py2', 'f2py2.6', 'f2py2.7',)
else: # on Windows and other Linux using python/f2py
options = ('f2py.exe', 'f2py.bat', 'f2py', 'f2py2.6', 'f2py2.7',
'f2py.py',)
for k in options:
if which(k):
# Found the f2py path, no need to look further
f2py_call = k
f2py_path = which(k)
break
try:
print('found f2py in:', f2py_path)
return f2py_call
except NameError:
raise UserWarning('Couldn\'t locate f2py. '
'Should be part of NumPy installation.')

@ -1,908 +0,0 @@
# /usr/bin/env python
'''
Module FIG
------------
Module for manipulating windows/figures created using
pylab or enthought.mayavi.mlab on the windows platform.
Figure manipulation involves
maximization, minimization, hiding, closing, stacking or tiling.
It is assumed that the figures are uniquely numbered in the following way:
Figure 1
Figure 2
....
or
TVTK scene 1
TVTK scene 2
TVTK scene 3
...
Example
-------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(6):
... f = p.figure(ix)
>>> fig.stack('all')
>>> fig.stack(1,2)
>>> fig.hide(1)
>>> fig.restore(1)
>>> fig.tile()
>>> fig.pile()
>>> fig.maximize(4)
>>> fig.close('all')
'''
from __future__ import absolute_import, division, print_function
# import win32api
import win32gui
import win32con
import wx
import numpy
from win32gui import (EnumWindows, MoveWindow, GetWindowRect, FindWindow,
ShowWindow, BringWindowToTop)
__all__ = ['close', 'cycle', 'hide', 'keep', 'maximize', 'minimize', 'pile',
'restore', 'stack', 'tile', 'find_all_figure_numbers', 'set_size']
# Figure format strings to recognize in window title
FIGURE_TITLE_FORMATS = ('Figure', 'TVTK Scene', 'Chaco Plot Window: Figure')
_SCREENSIZE = None
class CycleDialog(wx.Dialog):
def _get_buttons(self):
hbox = wx.BoxSizer(wx.HORIZONTAL)
buttons = ['Forward', 'Back', 'Cancel']
callbacks = [self.on_forward, self.on_backward, self.on_cancel]
for button, callback in zip(buttons, callbacks):
button = wx.Button(self, -1, button, size=(70, 30))
self.Bind(wx.EVT_BUTTON, callback, button)
hbox.Add(button, 1, wx.ALIGN_CENTER)
return hbox
def _get_message(self):
label = ('Press back or forward to display previous or next figure(s),'
' respectively. Press cancel to quit.')
message = wx.StaticText(self, label=label, size=(240, 25))
return message
def __init__(self, parent, interval=None, title='Cycle dialog'):
super(CycleDialog, self).__init__(parent, title=title, size=(260, 130))
if isinstance(interval, (float, int)):
self.interval_milli_sec = interval * 1000
else:
self.interval_milli_sec = 30
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.on_forward, self.timer)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(self._get_message(), 0, wx.ALIGN_CENTER | wx.TOP, 20)
vbox.Add(self._get_buttons(), 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
self.SetSizer(vbox)
def ShowModal(self, *args, **kwargs):
self.timer.Start(self.interval_milli_sec, oneShot=True)
return super(CycleDialog, self).ShowModal(*args, **kwargs)
def on_forward(self, evt):
self.EndModal(wx.ID_FORWARD)
def on_backward(self, evt):
self.EndModal(wx.ID_BACKWARD)
def on_cancel(self, evt):
self.EndModal(wx.ID_CANCEL)
def _get_cycle_dialog(parent=None, interval=None):
app = wx.GetApp()
if not app:
app = wx.App(redirect=False)
frame = wx.Frame(None)
app.SetTopWindow(frame)
dlg = CycleDialog(parent, interval)
return dlg
def get_window_position_and_size(window_handle):
pos = GetWindowRect(window_handle)
return pos[0], pos[1], pos[2] - pos[0], pos[3] - pos[1]
def get_screen_position_and_size(window_handles):
"""Return screen position; X, Y and size; width, height.
Parameters
----------
window_handles: list of handles to open window figures
(Note: only needed the first time)
Returns
--------
X : coordinate of the left side of the screen.
Y : coordinate of the top of the screen.
width : screen horizontal size
height : screen vertical size
"""
# pylint: disable=global-statement
global _SCREENSIZE
if _SCREENSIZE is None:
window_handle = window_handles[0]
pos = get_window_position_and_size(window_handle)
_show_windows((window_handle,), win32con.SW_SHOWMAXIMIZED)
_SCREENSIZE = get_window_position_and_size(window_handle)
MoveWindow(window_handle, pos[0], pos[1], pos[2], pos[3], 1)
return _SCREENSIZE
def _get_screen_size(wnds):
screen_width, screen_height = get_screen_position_and_size(wnds)[2:4]
return screen_width, screen_height
def _windowEnumerationHandler(handle, result_list):
"""Pass to win32gui.EnumWindows() to generate list of window handle, window
text tuples."""
# pylint: disable=no-member
if win32gui.IsWindowVisible(handle):
result_list.append((handle, win32gui.GetWindowText(handle)))
def _find_window_handles_and_titles(wantedTitle=None):
"""Return list of window handle and window title tuples.
Parameter
---------
wantedTitle:
"""
handles_n_titles = []
EnumWindows(_windowEnumerationHandler, handles_n_titles)
if wantedTitle is None:
return handles_n_titles
else:
return [(handle, title)
for handle, title in handles_n_titles
if title.startswith(wantedTitle)]
def find_figure_handles(*figure_numbers):
"""Find figure handles from figure numbers."""
wnd_handles = []
for figure_number in _parse_figure_numbers(*figure_numbers):
for format_ in FIGURE_TITLE_FORMATS:
winTitle = format_ + ' %d' % figure_number
handle = FindWindow(None, winTitle)
if not handle == 0:
wnd_handles.append(handle)
return wnd_handles
def find_all_figure_numbers():
"""Return list of all figure numbers.
Example
-------
>>> import fig
>>> import pylab as p
>>> for ix in range(5):
... f = p.figure(ix)
... p.draw()
fig.find_all_figure_numbers()
[0, 1, 2, 3, 4]
>>> fig.close()
"""
figure_numbers = []
for wantedTitle in FIGURE_TITLE_FORMATS:
handles_n_titles = _find_window_handles_and_titles(wantedTitle)
for _handle, title in handles_n_titles:
try:
number = int(title.split()[-1])
figure_numbers.append(number)
except (TypeError, ValueError):
pass
# pylint: disable=no-member
return numpy.unique(figure_numbers).tolist()
def _parse_figure_numbers(*args):
figure_numbers = []
for arg in args:
if isinstance(arg, (list, tuple, set)):
for val in arg:
figure_numbers.append(int(val))
elif isinstance(arg, int):
figure_numbers.append(arg)
elif arg == 'all':
figure_numbers = find_all_figure_numbers()
break
else:
raise TypeError('Only integers arguments accepted!')
if len(figure_numbers) == 0:
figure_numbers = find_all_figure_numbers()
return figure_numbers
def _show_figure(figure_numbers, command):
"""Sets the specified figure's show state.
Parameters
----------
figure_numbers: list of figure numbers
command: one of following commands:
SW_FORCEMINIMIZE:
Minimizes a window, even if the thread that owns the window is not
responding. This flag should only be used when minimizing windows
from a different thread.
SW_HIDE:
Hides the window and activates another window.
SW_MAXIMIZE:
Maximizes the specified window.
SW_MINIMIZE:
Minimizes the specified window and activates the next top-level window
in the Z order.
SW_RESTORE:
Activates and displays the window. If the window is minimized or
maximized, the system restores it to its original size and position.
An application should specify this flag when restoring a minimized
window.
SW_SHOW:
Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT:
Sets the show state based on the SW_ value specified in the STARTUPINFO
structure passed to the CreateProcess function by the program that
started the application.
SW_SHOWMAXIMIZED:
Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED:
Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE:
Displays the window as a minimized window. This value is similar to
SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNA:
Displays the window in its current size and position. This value is
similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATE:
Displays a window in its most recent size and position. This value is
similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL:
Activates and displays a window. If the window is minimized or
maximized, the system restores it to its original size and position.
An application should specify this flag when displaying the window for
the first time.
"""
for number in _parse_figure_numbers(*figure_numbers):
for format_ in FIGURE_TITLE_FORMATS:
title = format_ + ' %d' % number
handle = FindWindow(None, title)
if not handle == 0:
BringWindowToTop(handle)
ShowWindow(handle, command)
def _show_windows(handles, command, redraw_now=False):
"""Sets the specified window's show state.
Parameters
----------
handles: list of window handles
command: one of following commands:
SW_FORCEMINIMIZE:
Minimizes a window, even if the thread that owns the window is not
responding. This flag should only be used when minimizing windows
from a different thread.
SW_HIDE:
Hides the window and activates another window.
SW_MAXIMIZE:
Maximizes the specified window.
SW_MINIMIZE:
Minimizes the specified window and activates the next top-level window
in the Z order.
SW_RESTORE:
Activates and displays the window. If the window is minimized or
maximized, the system restores it to its original size and position.
An application should specify this flag when restoring a minimized
window.
SW_SHOW:
Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT:
Sets the show state based on the SW_ value specified in the STARTUPINFO
structure passed to the CreateProcess function by the program that
started the application.
SW_SHOWMAXIMIZED:
Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED:
Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE:
Displays the window as a minimized window. This value is similar to
SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNA:
Displays the window in its current size and position. This value is
similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATE:
Displays a window in its most recent size and position. This value is
similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL:
Activates and displays a window. If the window is minimized or
maximized, the system restores it to its original size and position.
An application should specify this flag when displaying the window for
the first time.
redraw_now :
"""
# pylint: disable=no-member
for handle in handles:
if not handle == 0:
BringWindowToTop(handle)
ShowWindow(handle, command)
if redraw_now:
rect = GetWindowRect(handle)
win32gui.RedrawWindow(handle, rect, None, win32con.RDW_UPDATENOW)
def keep(*figure_numbers):
"""Keeps figure windows of your choice and closes the rest.
Parameters
----------
figure_numbers : list of integers specifying which figures to keep.
Example:
--------
# keep only figures 1,2,3,5 and 7
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(10):
... f = p.figure(ix)
>>> fig.keep( range(1,4), 5, 7)
or
fig.keep([range(1,4), 5, 7])
>>> fig.close()
See also
--------
fig.close
"""
figs2keep = []
for fig in figure_numbers:
if isinstance(fig, (list, tuple, set)):
for val in fig:
figs2keep.append(int(val))
elif isinstance(fig, int):
figs2keep.append(fig)
else:
raise TypeError('Only integers arguments accepted!')
if len(figs2keep) > 0:
allfigs = set(find_all_figure_numbers())
figs2delete = allfigs.difference(figs2keep)
close(figs2delete)
def close(*figure_numbers):
""" Close figure window(s)
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to close (default 'all').
Examples
--------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(5):
... f = p.figure(ix)
>>> fig.close(3,4) # close figure 3 and 4
>>> fig.close('all') # close all remaining figures
or even simpler
fig.close() # close all remaining figures
See also
--------
fig.keep
"""
# pylint: disable=no-member
for handle in find_figure_handles(*figure_numbers):
if win32gui.SendMessage(handle, win32con.WM_CLOSE, 0, 0):
win32gui.SendMessage(handle, win32con.WM_DESTROY, 0, 0)
def restore(*figure_numbers):
"""Restore figures window size and position to its default value.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to restor (default 'all').
Description
-----------
RESTORE Activates and displays the window. If the window is minimized
or maximized, the system restores it to its original size and position.
Examples
---------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(5):
... f = p.figure(ix)
>>> fig.restore('all') #Restores all figures
>>> fig.restore() #same as restore('all')
>>> fig.restore(p.gcf().number) #Restores the current figure
>>> fig.restore(3) #Restores figure 3
>>> fig.restore([2, 4]) #Restores figures 2 and 4
or alternatively
fig.restore(2, 4)
>>> fig.close()
See also
--------
fig.close,
fig.keep
"""
SW_RESTORE = win32con.SW_RESTORE
# SW_RESTORE = win32con.SW_SHOWDEFAULT
# SW_RESTORE = win32con.SW_SHOWNORMAL
_show_figure(figure_numbers, SW_RESTORE)
def hide(*figure_numbers):
"""hide figure(s) window.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to hide (default 'all').
Examples:
--------
>>> import wafo.fig as fig
>>> import pylab as p
>>> for ix in range(5):
... f = p.figure(ix)
>>> fig.hide('all') #hides all unhidden figures
>>> fig.hide() #same as hide('all')
>>> fig.hide(p.gcf().number) #hides the current figure
>>> fig.hide(3) #hides figure 3
>>> fig.hide([2, 4]) #hides figures 2 and 4
or alternatively
fig.hide(2, 4)
>>> fig.restore(list(range(5)))
>>> fig.close()
See also
--------
fig.cycle,
fig.keep,
fig.restore
"""
_show_figure(figure_numbers, win32con.SW_HIDE)
def minimize(*figure_numbers):
"""Minimize figure(s) window size.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to minimize (default 'all').
Examples:
---------
>>> import wafo.fig as fig
>>> import pylab as p
>>> for ix in range(5):
... f = p.figure(ix)
>>> fig.minimize('all') #Minimizes all unhidden figures
>>> fig.minimize() #same as minimize('all')
>>> fig.minimize(p.gcf().number) #Minimizes the current figure
>>> fig.minimize(3) #Minimizes figure 3
>>> fig.minimize([2, 4]) #Minimizes figures 2 and 4
or alternatively
fig.minimize(2, 4)
>>> fig.close()
See also
--------
fig.cycle,
fig.keep,
fig.restore
"""
_show_figure(figure_numbers, win32con.SW_SHOWMINIMIZED)
def maximize(*figure_numbers):
"""Maximize figure(s) window size.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to maximize (default 'all').
Examples:
---------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(5):
... f = p.figure(ix)
>>> fig.maximize('all') #Maximizes all unhidden figures
>>> fig.maximize() #same as maximize('all')
>>> fig.maximize(p.gcf().number) #Maximizes the current figure
>>> fig.maximize(3) #Maximizes figure 3
>>> fig.maximize([2, 4]) #Maximizes figures 2 and 4
or alternatively
fig.maximize(2, 4)
>>> fig.close()
See also
--------
fig.cycle,
fig.keep,
fig.restore
"""
_show_figure(figure_numbers, win32con.SW_SHOWMAXIMIZED)
def pile(*figure_numbers, **kwds):
"""Pile figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to pile (default 'all').
kwds : dict with the following keys
position :
width :
height :
Description
-------------
PILE piles all open figure windows on top of eachother
with complete overlap. PILE(FIGS) can be used to specify which
figures that should be piled. Figures are not sorted when specified.
Example:
--------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(7):
... f = p.figure(ix)
>>> fig.pile() # pile all open figures
>>> fig.pile(range(1,4), 5, 7) # pile figure 1,2,3,5 and 7
>>> fig.close()
See also
--------
fig.cycle, fig.keep, fig.maximize, fig.restore,
fig.stack, fig.tile
"""
wnds = find_figure_handles(*figure_numbers)
numfigs = len(wnds)
if numfigs > 0:
screen_width, screen_height = _get_screen_size(wnds)
pos = kwds.get(
'position', (int(screen_width / 5), int(screen_height / 4)))
width = kwds.get('width', int(screen_width / 2.5))
height = kwds.get('height', int(screen_height / 2))
for wnd in wnds:
MoveWindow(wnd, pos[0], pos[1], width, height, 1)
BringWindowToTop(wnd)
def set_size(*figure_numbers, **kwds):
"""Set size for figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to pile (default 'all').
kwds : dict with the following keys
width :
height :
Description
-------------
Set size sets the size of all open figure windows. SET_SIZE(FIGS)
can be used to specify which figures that should be resized.
Figures are not sorted when specified.
Example:
--------
>>> import pylab as p
>>> import fig
>>> for ix in range(7):
... f = p.figure(ix)
>>> fig.set_size(7, width=150, height=100)
>>> fig.set_size(range(1,4), 5,width=250, height=170)
>>> fig.close()
See also
--------
fig.cycle, fig.keep, fig.maximize, fig.restore,
fig.stack, fig.tile
"""
handles = find_figure_handles(*figure_numbers)
numfigs = len(handles)
if numfigs > 0:
screen_width, screen_height = _get_screen_size(handles)
width = kwds.get('width', int(screen_width / 2.5))
height = kwds.get('height', int(screen_height / 2))
new_pos = kwds.get('position', None)
pos = new_pos
for handle in handles:
if not new_pos:
pos = get_window_position_and_size(handle)
MoveWindow(handle, pos[0], pos[1], width, height, 1)
BringWindowToTop(handle)
def stack(*figure_numbers, **kwds):
"""Stack figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to stack (default 'all').
kwds : dict with the following keys
figs_per_stack :
number of figures per stack (default depends on screenheight)
Description
-----------
STACK stacks all open figure windows on top of eachother
with maximum overlap. STACK(FIGS) can be used to specify which
figures that should be stacked. Figures are not sorted when specified.
Example:
--------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(7):
... f = p.figure(ix)
>>> fig.stack() # stack all open figures
>>> fig.stack(range(1,4), 5, 7) # stack figure 1,2,3,5 and 7
>>> fig.close()
See also
--------
fig.cycle, fig.keep, fig.maximize, fig.restore,
fig.pile, fig.tile
"""
wnds = find_figure_handles(*figure_numbers)
numfigs = len(wnds)
if numfigs > 0:
screenpos = get_screen_position_and_size(wnds)
y_step = 25
x_step = border = 5
figs_per_stack = kwds.get(
'figs_per_stack',
int(numpy.fix(0.7 * (screenpos[3] - border) / y_step)))
for iy in range(numfigs):
pos = get_window_position_and_size(wnds[iy])
# print('[x, y, w, h] = ', pos)
ix = iy % figs_per_stack
ypos = int(screenpos[1] + ix * y_step + border)
xpos = int(screenpos[0] + ix * x_step + border)
MoveWindow(wnds[iy], xpos, ypos, pos[2], pos[3], 1)
BringWindowToTop(wnds[iy])
def tile(*figure_numbers, **kwds):
"""Tile figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to tile (default 'all').
kwds : dict with key pairs
specifying how many pairs of figures that are tiled at a time
Description
-----------
TILE places all open figure windows around on the screen with no
overlap. TILE(FIGS) can be used to specify which figures that
should be tiled. Figures are not sorted when specified.
Example:
--------
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(7):
... f = p.figure(ix)
>>> fig.tile() # tile all open figures
>>> fig.tile( range(1,4), 5, 7) # tile figure 1,2,3,5 and 7
>>> fig.tile(range(1,11), pairs=2) # tile figure 1 to 10 two at a time
>>> fig.tile(range(1,11), pairs=3) # tile figure 1 to 10 three at a time
>>> fig.close()
See also
--------
fig.cycle, fig.keep, fig.maximize, fig.minimize
fig.restore, fig.pile, fig.stack
"""
wnds = find_figure_handles(*figure_numbers)
nfigs = len(wnds)
# Number of windows.
if nfigs > 0:
nfigspertile = kwds.get('pairs', nfigs)
ceil = numpy.ceil
sqrt = numpy.sqrt
maximum = numpy.maximum
nlayers = int(ceil(nfigs / nfigspertile))
# Number of figures horisontally.
nh = maximum(int(ceil(sqrt(nfigspertile))), 2)
# Number of figures vertically.
nv = maximum(int(ceil(nfigspertile / nh)), 2)
screenpos = get_screen_position_and_size(wnds)
screen_width, screen_heigth = screenpos[2:4]
hspc = 10 # Horisontal space.
topspc = 20 # Space above top figure.
medspc = 10 # Space between figures.
botspc = 20 # Space below bottom figure.
figwid = (screen_width - (nh + 1) * hspc) / nh
fighgt = (screen_heigth - (topspc + botspc) - (nv - 1) * medspc) / nv
figwid = int(numpy.round(figwid))
fighgt = int(numpy.round(fighgt))
idx = 0
for unused_ix in range(nlayers):
for row in range(nv):
figtop = int(screenpos[1] + topspc + row * (fighgt + medspc))
for col in range(nh):
if (row) * nh + col < nfigspertile:
if idx < nfigs:
figlft = int(
screenpos[0] + (col + 1) * hspc + col * figwid)
fighnd = wnds[idx]
MoveWindow(fighnd, figlft, figtop, figwid, fighgt,
1)
# Set position.
BringWindowToTop(fighnd)
idx += 1
class _CycleGenerator(object):
"""Cycle through figure windows.
Parameters
----------
figure_numbers : list of integers or string
specifying which figures to cycle through (default 'all').
kwds : dict with the following keys
pairs : number of figures to cycle in pairs (default 1)
maximize: If True maximize figure when viewing (default False)
interval : pause interval in seconds
Description
-----------
CYCLE brings up all open figure in ascending order and pauses after
each figure. Press escape to quit cycling, backspace to display previous
figure(s) and press any other key to display next figure(s)
When done, the figures are sorted in ascending order.
CYCLE(maximize=True) does the same thing, except figures are maximized.
CYCLE(pairs=2) cycle through all figures in pairs of 2.
Examples:
>>> import pylab as p
>>> import wafo.fig as fig
>>> for ix in range(4):
... f = p.figure(ix)
fig.cycle(range(3), interval=1) # Cycle trough figure 0 to 2
# Cycle trough figure 0 to 2 with figures maximized
fig.cycle(range(3), maximize=True, interval=1)
fig.cycle(interval=1) # Cycle through all figures one at a time
fig.tile(pairs=2, interval=1)
fig.cycle(pairs=2, interval=2) # Cycle through all figures two at a time
fig.cycle(pairs=2) # Manually cycle through all figures two at a time
>>> fig.close()
See also
--------
fig.keep, fig.maximize, fig.restore, fig.pile,
fig.stack, fig.tile
"""
escape_key = chr(27)
backspace_key = chr(8)
def __init__(self, **kwds):
self.dialog = None
maximize = kwds.get('maximize', False)
pairs = kwds.get('pairs', 1)
self.interval = kwds.get('interval', 'user_defined')
self.nfigspercycle = 1
if maximize:
self.command = win32con.SW_SHOWMAXIMIZED
else:
self.command = win32con.SW_SHOWNORMAL
if pairs is not None:
self.nfigspercycle = pairs
def _set_options(self, kwds):
self.__init__(**kwds)
def _iterate(self, handles):
i = 0
numfigs = len(handles)
self.dialog = _get_cycle_dialog(parent=None, interval=self.interval)
while 0 <= i and i < numfigs:
iu = min(i + self.nfigspercycle, numfigs)
yield handles[i:iu]
i = self.next_index(i)
self.dialog.Destroy()
raise StopIteration
def next_index(self, i):
result = self.dialog.ShowModal()
if result == wx.ID_FORWARD:
i += self.nfigspercycle
elif result == wx.ID_BACKWARD:
i -= self.nfigspercycle
else:
i = -1
return i
def __call__(self, *figure_numbers, **kwds):
handles = find_figure_handles(*figure_numbers)
numfigs = len(handles)
if numfigs > 0:
self._set_options(kwds)
for handle in self._iterate(handles):
_show_windows(handle, self.command, redraw_now=True)
_show_windows(handles, win32con.SW_SHOWNORMAL)
cycle = _CycleGenerator()
if __name__ == '__main__':
from wafo.testing import test_docstrings
import matplotlib
matplotlib.interactive(True)
test_docstrings(__file__)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,538 +0,0 @@
"""
Created on 20. aug. 2015
@author: pab
"""
from __future__ import division
from collections import namedtuple
import warnings
import numdifftools as nd
import numdifftools.nd_algopy as nda
from numdifftools.extrapolation import dea3
from numdifftools.limits import Limit
import numpy as np
from numpy import linalg
from numpy.polynomial.chebyshev import chebval, Chebyshev
from numpy.polynomial import polynomial
from wafo.misc import piecewise, findcross, ecross
_FINFO = np.finfo(float)
EPS = _FINFO.eps
_EPS = EPS
_TINY = _FINFO.tiny
_HUGE = _FINFO.max
def _assert(cond, msg):
if not cond:
raise ValueError(msg)
def _assert_warn(cond, msg):
if not cond:
warnings.warn(msg)
class PolyBasis(object):
@staticmethod
def _derivative(c, m):
return polynomial.polyder(c, m)
@staticmethod
def eval(t, c):
return polynomial.polyval(t, c)
@staticmethod
def _coefficients(k):
c = np.zeros(k + 1)
c[k] = 1
return c
def derivative(self, t, k, n=1):
c = self._coefficients(k)
d_c = self._derivative(c, m=n)
return self.eval(t, d_c)
def __call__(self, t, k):
return t**k
poly_basis = PolyBasis()
class ChebyshevBasis(PolyBasis):
@staticmethod
def _derivative(c, m):
cheb = Chebyshev(c)
dcheb = cheb.deriv(m=m)
return dcheb.coef
@staticmethod
def eval(t, c):
return chebval(t, c)
def __call__(self, t, k):
c = self._coefficients(k)
return self.eval(t, c)
chebyshev_basis = ChebyshevBasis()
def richardson(q_val, k):
# license BSD
# Richardson extrapolation with parameter estimation
c = np.real((q_val[k - 1] - q_val[k - 2]) / (q_val[k] - q_val[k - 1])) - 1.
# The lower bound 0.07 admits the singularity x.^-0.9
c = max(c, 0.07)
return q_val[k] + (q_val[k] - q_val[k - 1]) / c
def evans_webster_weights(omega, g, d_g, x, basis, *args, **kwds):
def psi(t, k):
return d_g(t, *args, **kwds) * basis(t, k)
j_w = 1j * omega
n = len(x)
a_matrix = np.zeros((n, n), dtype=complex)
rhs = np.zeros((n,), dtype=complex)
dbasis = basis.derivative
lim_g = Limit(g)
b_1 = np.exp(j_w * lim_g(1, *args, **kwds))
if np.isnan(b_1):
b_1 = 0.0
a_1 = np.exp(j_w * lim_g(-1, *args, **kwds))
if np.isnan(a_1):
a_1 = 0.0
lim_psi = Limit(psi)
for k in range(n):
rhs[k] = basis(1, k) * b_1 - basis(-1, k) * a_1
a_matrix[k] = (dbasis(x, k, n=1) + j_w * lim_psi(x, k))
solution = linalg.lstsq(a_matrix, rhs)
return solution[0]
def osc_weights(omega, g, d_g, x, basis, a_b, *args, **kwds):
def _g(t):
return g(scale * t + offset, *args, **kwds)
def _d_g(t):
return scale * d_g(scale * t + offset, *args, **kwds)
w = []
for a, b in zip(a_b[::2], a_b[1::2]):
scale = (b - a) / 2
offset = (a + b) / 2
w.append(evans_webster_weights(omega, _g, _d_g, x, basis))
return np.asarray(w).ravel()
class _Integrator(object):
info = namedtuple('info', ['error_estimate', 'n'])
def __init__(self, f, g, dg=None, a=-1, b=1, basis=chebyshev_basis, s=1,
precision=10, endpoints=True, full_output=False):
self.f = f
self.g = g
self.dg = nd.Derivative(g) if dg is None else dg
self.basis = basis
self.a = a
self.b = b
self.s = s
self.endpoints = endpoints
self.precision = precision
self.full_output = full_output
class QuadOsc(_Integrator):
def __init__(self, f, g, dg=None, a=-1, b=1, basis=chebyshev_basis, s=15,
precision=10, endpoints=False, full_output=False, maxiter=17):
self.maxiter = maxiter
super(QuadOsc, self).__init__(f, g, dg=dg, a=a, b=b, basis=basis, s=s,
precision=precision, endpoints=endpoints,
full_output=full_output)
@staticmethod
def _change_interval_to_0_1(f, g, d_g, a, _b):
def f_01(t, *args, **kwds):
den = 1 - t
return f(a + t / den, *args, **kwds) / den ** 2
def g_01(t, *args, **kwds):
return g(a + t / (1 - t), *args, **kwds)
def d_g_01(t, *args, **kwds):
den = 1 - t
return d_g(a + t / den, *args, **kwds) / den ** 2
return f_01, g_01, d_g_01, 0., 1.
@staticmethod
def _change_interval_to_m1_0(f, g, d_g, _a, b):
def f_m10(t, *args, **kwds):
den = 1 + t
return f(b + t / den, *args, **kwds) / den ** 2
def g_m10(t, *args, **kwds):
return g(b + t / (1 + t), *args, **kwds)
def d_g_m10(t, *args, **kwds):
den = 1 + t
return d_g(b + t / den, *args, **kwds) / den ** 2
return f_m10, g_m10, d_g_m10, -1.0, 0.0
@staticmethod
def _change_interval_to_m1_1(f, g, d_g, _a, _b):
def f_m11(t, *args, **kwds):
den = (1 - t**2)
return f(t / den, *args, **kwds) * (1 + t**2) / den ** 2
def g_m11(t, *args, **kwds):
den = (1 - t**2)
return g(t / den, *args, **kwds)
def d_g_m11(t, *args, **kwds):
den = (1 - t**2)
return d_g(t / den, *args, **kwds) * (1 + t**2) / den ** 2
return f_m11, g_m11, d_g_m11, -1., 1.
def _get_functions(self):
a, b = self.a, self.b
reverse = np.real(a) > np.real(b)
if reverse:
a, b = b, a
f, g, dg = self.f, self.g, self.dg
if a == b:
pass
elif np.isinf(a) | np.isinf(b):
# Check real limits
if ~np.isreal(a) | ~np.isreal(b) | np.isnan(a) | np.isnan(b):
raise ValueError('Infinite intervals must be real.')
# Change of variable
if np.isfinite(a) & np.isinf(b):
f, g, dg, a, b = self._change_interval_to_0_1(f, g, dg, a, b)
elif np.isinf(a) & np.isfinite(b):
f, g, dg, a, b = self._change_interval_to_m1_0(f, g, dg, a, b)
else: # -inf to inf
f, g, dg, a, b = self._change_interval_to_m1_1(f, g, dg, a, b)
return f, g, dg, a, b, reverse
def __call__(self, omega, *args, **kwds):
f, g, dg, a, b, reverse = self._get_functions()
val, err = self._quad_osc(f, g, dg, a, b, omega, *args, **kwds)
if reverse:
val = -val
if self.full_output:
return val, err
return val
@staticmethod
def _get_best_estimate(k, q_0, q_1, q_2):
if k >= 5:
q_v = np.hstack((q_0[k], q_1[k], q_2[k]))
q_w = np.hstack((q_0[k - 1], q_1[k - 1], q_2[k - 1]))
elif k >= 3:
q_v = np.hstack((q_0[k], q_1[k]))
q_w = np.hstack((q_0[k - 1], q_1[k - 1]))
else:
q_v = np.atleast_1d(q_0[k])
q_w = q_0[k - 1]
errors = np.atleast_1d(abs(q_v - q_w))
j = np.nanargmin(errors)
return q_v[j], errors[j]
def _extrapolate(self, k, q_0, q_1, q_2):
if k >= 4:
q_1[k] = dea3(q_0[k - 2], q_0[k - 1], q_0[k])[0]
q_2[k] = dea3(q_1[k - 2], q_1[k - 1], q_1[k])[0]
elif k >= 2:
q_1[k] = dea3(q_0[k - 2], q_0[k - 1], q_0[k])[0]
# # Richardson extrapolation
# if k >= 4:
# q_1[k] = richardson(q_0, k)
# q_2[k] = richardson(q_1, k)
# elif k >= 2:
# q_1[k] = richardson(q_0, k)
q, err = self._get_best_estimate(k, q_0, q_1, q_2)
return q, err
def _quad_osc(self, f, g, dg, a, b, omega, *args, **kwds):
if a == b:
q_val = b - a
err = np.abs(b - a)
return q_val, err
abseps = 10**-self.precision
max_iter = self.maxiter
basis = self.basis
if self.endpoints:
x_n = chebyshev_extrema(self.s)
else:
x_n = chebyshev_roots(self.s)
# x_n = tanh_sinh_open_nodes(self.s)
# One interval
hh = (b - a) / 2
x = (a + b) / 2 + hh * x_n # Nodes
dtype = complex
val0 = np.zeros((max_iter, 1), dtype=dtype) # Quadrature
val1 = np.zeros((max_iter, 1), dtype=dtype) # First extrapolation
val2 = np.zeros((max_iter, 1), dtype=dtype) # Second extrapolation
lim_f = Limit(f)
a_b = np.hstack([a, b])
wq = osc_weights(omega, g, dg, x_n, basis, a_b, *args, **kwds)
val0[0] = hh * np.sum(wq * lim_f(x, *args, **kwds))
# Successive bisection of intervals
nq = len(x_n)
n = nq
for k in range(1, max_iter):
n += nq * 2**k
hh = hh / 2
x = np.hstack([x + a, x + b]) / 2
a_b = np.hstack([a_b + a, a_b + b]) / 2
wq = osc_weights(omega, g, dg, x_n, basis, a_b, *args, **kwds)
val0[k] = hh * np.sum(wq * lim_f(x, *args, **kwds))
q_val, err = self._extrapolate(k, val0, val1, val2)
converged = (err <= abseps) | ~np.isfinite(q_val)
if converged:
break
_assert_warn(converged, 'Max number of iterations reached '
'without convergence.')
_assert_warn(np.isfinite(q_val),
'Integral approximation is Infinite or NaN.')
# The error estimate should not be zero
err += 2 * np.finfo(q_val).eps
return q_val, self.info(err, n)
def adaptive_levin_points(m, delta):
m_1 = m - 1
prm = 0.5
while prm * m_1 / delta >= 1:
delta = 2 * delta
k = np.arange(m)
x = piecewise([k < prm * m_1, k == np.ceil(prm * m_1)],
[-1 + k / delta, 0 * k, 1 - (m_1 - k) / delta])
return x
def open_levin_points(m, delta):
return adaptive_levin_points(m + 2, delta)[1:-1]
def chebyshev_extrema(m, delta=None):
k = np.arange(m)
x = np.cos(k * np.pi / (m - 1))
return x
def tanh_sinh_nodes(m, delta=None, tol=_EPS):
tmax = np.arcsinh(np.arctanh(1 - _EPS) * 2 / np.pi)
# tmax = 3.18
m_1 = int(np.floor(-np.log2(tmax / max(m - 1, 1)))) - 1
h = 2.0**-m_1
t = np.arange((m + 1) // 2 + 1) * h
x = np.tanh(np.pi / 2 * np.sinh(t))
k = np.flatnonzero(np.abs(x - 1) <= 10 * tol)
y = x[:k[0] + 1] if len(k) else x
return np.hstack((-y[:0:-1], y))
def tanh_sinh_open_nodes(m, delta=None, tol=_EPS):
return tanh_sinh_nodes(m + 1, delta, tol)[1:-1]
def chebyshev_roots(m, delta=None):
k = np.arange(1, 2 * m, 2) * 0.5
x = np.cos(k * np.pi / m)
return x
class AdaptiveLevin(_Integrator):
"""Return integral for the Levin-type and adaptive Levin-type methods"""
@staticmethod
def _a_levin(omega, f, g, d_g, x, s, basis, *args, **kwds):
def psi(t, k):
return d_g(t, *args, **kwds) * basis(t, k)
j_w = 1j * omega
nu = np.ones((len(x),), dtype=int)
nu[0] = nu[-1] = s
S = np.cumsum(np.hstack((nu, 0)))
S[-1] = 0
n = int(S[-2])
a_matrix = np.zeros((n, n), dtype=complex)
rhs = np.zeros((n,))
dff = Limit(nda.Derivative(f))
d_psi = Limit(nda.Derivative(psi))
dbasis = basis.derivative
for r, t in enumerate(x):
for j in range(S[r - 1], S[r]):
order = ((j - S[r - 1]) % nu[r]) # derivative order
dff.fun.n = order
rhs[j] = dff(t, *args, **kwds)
d_psi.fun.n = order
for k in range(n):
a_matrix[j, k] = (dbasis(t, k, n=order + 1) +
j_w * d_psi(t, k))
k1 = np.flatnonzero(1 - np.isfinite(rhs))
if k1.size > 0: # Remove singularities
warnings.warn('Singularities detected! ')
a_matrix[k1] = 0
rhs[k1] = 0
solution = linalg.lstsq(a_matrix, rhs)
v = basis.eval([-1, 1], solution[0])
lim_g = Limit(g)
g_b = np.exp(j_w * lim_g(1, *args, **kwds))
if np.isnan(g_b):
g_b = 0
g_a = np.exp(j_w * lim_g(-1, *args, **kwds))
if np.isnan(g_a):
g_a = 0
return v[1] * g_b - v[0] * g_a
def _get_integration_limits(self, omega, args, kwds):
a, b = self.a, self.b
M = 30
ab = [a]
scale = (b - a) / 2
n = 30
x = np.linspace(a, b, n + 1)
dg_x = np.asarray([scale * omega * self.dg(xi, *args, **kwds)
for xi in x])
i10 = findcross(dg_x, M)
i1 = findcross(dg_x, 1)
i0 = findcross(dg_x, 0)
im1 = findcross(dg_x, -1)
im10 = findcross(dg_x, -M)
x10 = ecross(x, dg_x, i10, M) if len(i10) else ()
x1 = ecross(x, dg_x, i1, 1) if len(i1) else ()
x0 = ecross(x, dg_x, i0, 0) if len(i0) else ()
xm1 = ecross(x, dg_x, im1, -1) if len(im1) else ()
xm10 = ecross(x, dg_x, im10, -M) if len(im10) else ()
for i in np.unique(np.hstack((x10, x1, x0, xm1, xm10))):
if x[0] < i < x[n]:
ab.append(i)
ab.append(b)
return ab
def __call__(self, omega, *args, **kwds):
ab = self._get_integration_limits(omega, args, kwds)
s = self.s
val = 0
n = 0
err = 0
for ai, bi in zip(ab[:-1], ab[1:]):
vali, infoi = self._QaL(s, ai, bi, omega, *args, **kwds)
val += vali
err += infoi.error_estimate
n += infoi.n
if self.full_output:
info = self.info(err, n)
return val, info
return val
@staticmethod
def _get_num_points(s, prec, betam):
return 1 if s > 1 else int(prec / max(np.log10(betam + 1), 1) + 1)
def _QaL(self, s, a, b, omega, *args, **kwds):
"""if s>1,the integral is computed by Q_s^L"""
scale = (b - a) / 2
offset = (a + b) / 2
prec = self.precision # desired precision
def ff(t, *args, **kwds):
return scale * self.f(scale * t + offset, *args, **kwds)
def gg(t, *args, **kwds):
return self.g(scale * t + offset, *args, **kwds)
def dgg(t, *args, **kwds):
return scale * self.dg(scale * t + offset, *args, **kwds)
dg_a = abs(omega * dgg(-1, *args, **kwds))
dg_b = abs(omega * dgg(1, *args, **kwds))
g_a = abs(omega * gg(-1, *args, **kwds))
g_b = abs(omega * gg(1, *args, **kwds))
delta, alpha = min(dg_a, dg_b), min(g_a, g_b)
betam = delta # * scale
if self.endpoints:
if delta < 10 or alpha <= 10 or s > 1:
points = chebyshev_extrema
else:
points = adaptive_levin_points
elif delta < 10 or alpha <= 10 or s > 1:
points = chebyshev_roots
else:
points = open_levin_points # tanh_sinh_open_nodes
m = self._get_num_points(s, prec, betam)
abseps = 10 * 10.0**-prec
num_collocation_point_list = m * 2**np.arange(1, 5) + 1
basis = self.basis
q_val = 1e+300
num_function_evaluations = 0
n = 0
for num_collocation_points in num_collocation_point_list:
n_old = n
q_old = q_val
x = points(num_collocation_points, betam)
n = len(x)
if n > n_old:
q_val = self._a_levin(omega, ff, gg, dgg, x, s, basis, *args,
**kwds)
num_function_evaluations += n
err = np.abs(q_val - q_old)
if err <= abseps:
break
info = self.info(err, num_function_evaluations)
return q_val, info
class EvansWebster(AdaptiveLevin):
"""Return integral for the Evans Webster method"""
def __init__(self, f, g, dg=None, a=-1, b=1, basis=chebyshev_basis, s=8,
precision=10, endpoints=False, full_output=False):
super(EvansWebster,
self).__init__(f, g, dg=dg, a=a, b=b, basis=basis, s=s,
precision=precision, endpoints=endpoints,
full_output=full_output)
def _a_levin(self, omega, ff, gg, dgg, x, s, basis, *args, **kwds):
w = evans_webster_weights(omega, gg, dgg, x, basis, *args, **kwds)
f = Limit(ff)(x, *args, **kwds)
return np.sum(f * w)
def _get_num_points(self, s, prec, betam):
return 8 if s > 1 else int(prec / max(np.log10(betam + 1), 1) + 1)
if __name__ == '__main__':
tanh_sinh_nodes(16)

@ -9,10 +9,10 @@ import numpy as np
import warnings
from wafo.plotbackend import plotbackend as plt
from wafo.kdetools import Kernel, TKDE, KDE, KRegression, BKRegression
try:
from wafo import fig
except ImportError:
warnings.warn('fig import only supported on Windows')
# try:
# from wafo import fig
# except ImportError:
# warnings.warn('fig import only supported on Windows')
__all__ = ['kde_demo1', 'kde_demo2', 'kde_demo3', 'kde_demo4', 'kde_demo5',
'kreg_demo1', ]

@ -19,11 +19,11 @@ import warnings
from time import strftime, gmtime
from wafo.plotbackend import plotbackend as plt
import numbers
try:
from wafo import c_library as clib # @UnresolvedImport
except ImportError:
warnings.warn('c_library not found. Check its compilation.')
clib = None
# try:
# from wafo import c_library as clib # @UnresolvedImport
# except ImportError:
# warnings.warn('c_library not found. Check its compilation.')
# clib = None
FLOATINFO = np.finfo(float)
_TINY = FLOATINFO.tiny
_EPS = FLOATINFO.eps

@ -441,7 +441,7 @@ def disufq(rA, iA, w, kw, h, g, nmin, nmax, m, n):
return rvec, ivec
@jit(int32[:](float64[:], float64[:], float64[:, :]))
# @jit(int32[:](float64[:], float64[:], float64[:, :]))
def _findrfc3_astm(array_ext, a, array_out):
"""
Rain flow without time analysis
@ -489,7 +489,7 @@ def _findrfc3_astm(array_ext, a, array_out):
return c_nr1, c_nr2
@jit(int32[:](float64[:], float64[:], float64[:], float64[:], float64[:, :]))
# @jit(int32[:](float64[:], float64[:], float64[:], float64[:], float64[:, :]))
def _findrfc5_astm(array_ext, array_t, a, t, array_out):
"""
Rain flow with time analysis

@ -13,15 +13,15 @@
from __future__ import absolute_import, division
from wafo.transform.core import TrData
from wafo.transform.estimation import TransformEstimator
from wafo.stats import distributions
# from wafo.transform.core import TrData
# from wafo.transform.estimation import TransformEstimator
# from wafo.stats import distributions
from wafo.misc import (nextpow2, findtp, findrfc, findtc, findcross,
ecross, JITImport, DotDict, gravity, findrfc_astm,
detrendma)
from wafo.interpolate import stineman_interp
# from wafo.interpolate import stineman_interp
from wafo.containers import PlotData
from wafo.plotbackend import plotbackend as plt
# from wafo.plotbackend import plotbackend as plt
from scipy.integrate import trapz
from scipy.signal import welch, lfilter
from scipy.signal.windows import get_window # @UnusedImport

@ -1,532 +0,0 @@
'''
All the software contained in this library is protected by copyright.
Permission to use, copy, modify, and distribute this software for any
purpose without fee is hereby granted, provided that this entire notice
is included in all copies of any software which is or includes a copy
or modification of this software and in all copies of the supporting
documentation for such software.
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
WARRANTY. IN NO EVENT, NEITHER THE AUTHORS, NOR THE PUBLISHER, NOR ANY
MEMBER OF THE EDITORIAL BOARD OF THE JOURNAL "NUMERICAL ALGORITHMS",
NOR ITS EDITOR-IN-CHIEF, BE LIABLE FOR ANY ERROR IN THE SOFTWARE, ANY
MISUSE OF IT OR ANY DAMAGE ARISING OUT OF ITS USE. THE ENTIRE RISK OF
USING THE SOFTWARE LIES WITH THE PARTY DOING SO.
ANY USE OF THE SOFTWARE CONSTITUTES ACCEPTANCE OF THE TERMS OF THE
ABOVE STATEMENT.
AUTHORS:
Per A Brodtkorb
Python code Based on matlab code written by:
Marco Caliari
University of Verona, Italy
E-mail: marco.caliari@univr.it
Stefano de Marchi, Alvise Sommariva, Marco Vianello
University of Padua, Italy
E-mail: demarchi@math.unipd.it, alvise@math.unipd.it,
marcov@math.unipd.it
Reference
---------
Padua2DM: fast interpolation and cubature at the Padua points in Matlab/Octave
NUMERICAL ALGORITHMS, 56 (2011), PP. 45-60
Padua module
------------
In polynomial interpolation of two variables, the Padua points are the first
known example (and up to now the only one) of a unisolvent point set
(that is, the interpolating polynomial is unique) with minimal growth of their
Lebesgue constant, proven to be O(log2 n).
This module provides all the functions needed to perform interpolation and
cubature at the Padua points, together with the functions and the demos used
in the paper.
pdint.m : main function for interpolation at the Padua points
pdcub.m : main function for cubature at the Padua points
pdpts.m : function for the computation of the Padua points
padua_fit.m : function for the computation of the interpolation
coefficients by FFT (recommended)
pdcfsMM.m : function for the computation of the interpolation
coefficients by matrix multiplications
pdval.m : function for the evaluation of the interpolation
polynomial
pdwtsFFT.m : function for the computation of the cubature
weights by FFT
pdwtsMM.m : function for the computation of the cubature
weights by matrix multiplications (recommended)
funct.m : function containing some test functions
demo_pdint.m : demo script for pdint
demo_cputime_pdint.m : demo script for the computation of CPU time for
interpolation
demo_errors_pdint.m : demo script for the comparison of interpolation with
coefficients computed by FFT or by matrix
multiplications
demo_pdcub : demo script for pdcub
demo_cputime_pdcub.m : demo script for the computation of CPU time for
cubature
demo_errors_pdcub.m : demo script for the comparison of cubature with
weights computed by FFT or by matrix multiplications
demo_errors_pdcub_gl.m : demo script for the comparison of different cubature
formulas
cubature_square.m : function for the computation of some cubature
formulas for the square
omelyan_solovyan_rule.m : function for the computation of Omelyan-Solovyan
cubature points and weights
Contents.m : Contents file for Matlab
'''
from __future__ import absolute_import, division
import numpy as np
from numpy.fft import fft
from wafo.dctpack import dct
from wafo.polynomial import map_from_interval, map_to_interval
# from scipy.fftpack.realtransforms import dct
class _ExampleFunctions(object):
'''
Computes test function in the points (x, y)
Parameters
----------
x,y : array-like
evaluate the function in the points (x,y)
i : scalar int (default 0)
defining which test function to use. Options are
0: franke
1: half_sphere
2: poly_degree20
3: exp_fun1
4: exp_fun100
5: cos30
6: constant
7: exp_xy
8: runge
9: abs_cubed
10: gauss
11: exp_inv
Returns
-------
z : array-like
value of the function in the points (x,y)
'''
@staticmethod
def franke(x, y):
'''Franke function.
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500, is
2.1547794245591083e+000 with an estimated absolute error of 8.88e-016.
The value of the definite integral on the square [0,1] x [0,1],
obtained using a Padua Points cubature formula of degree 500, is
4.06969589491556e-01 with an estimated absolute error of 8.88e-016.
Maple: 0.40696958949155611906
'''
def _exp(x, y, loc, scale, p2=2):
return np.exp(- (x - loc[0])**2 / scale[0] - (y - loc[1])**p2 / scale[1])
# exp = np.exp
x9, y9 = 9. * x, 9. * y
return (3. / 4 * _exp(x9, y9, [2, 2], [4, 4]) +
3. / 4 * _exp(x9, y9, [-1, -1], [49, 10], p2=1) +
1. / 2 * _exp(x9, y9, [7, 3], [4, 4]) -
1. / 5 * _exp(x9, y9, [4, 7], [1, 1]))
@staticmethod
def half_sphere(x, y):
'''The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 2000, is
3.9129044444568244e+000 with an estimated absolute error of 3.22e-010.
'''
return ((x - 0.5)**2 + (y - 0.5)**2)**(1. / 2)
@staticmethod
def poly_degree20(x, y):
''''Bivariate polynomial having moderate degree.
The value of the definite integral on the square [-1,1] x
[-1,1], up to machine precision, is 18157.16017316017 (see ref. 6).
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 1.8157160173160162e+004.
2D modification of an example by L.N.Trefethen (see ref. 7), f(x)=x^20.
'''
return (x + y)**20
@staticmethod
def exp_fun1(x, y):
''' The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 2000,
is 2.1234596326670683e+001 with an estimated absolute error of
7.11e-015.
'''
return np.exp((x - 0.5)**2 + (y - 0.5)**2)
@staticmethod
def exp_fun100(x, y):
'''The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 2000,
is 3.1415926535849605e-002 with an estimated absolute error of
3.47e-017.
'''
return np.exp(-100 * ((x - 0.5)**2 + (y - 0.5)**2))
@staticmethod
def cos30(x, y):
''' The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 4.3386955120336568e-003 with an estimated absolute error of
2.95e-017.
'''
return np.cos(30 * (x + y))
@staticmethod
def constant(x, y):
'''Constant.
To test interpolation and cubature at degree 0.
The value of the definite integral on the square [-1,1] x [-1,1]
is 4.
'''
return np.ones(np.shape(x + y))
@staticmethod
def exp_xy(x, y):
'''The value of the definite integral on the square [-1,1] x [-1,1]
is up to machine precision is 5.524391382167263 (see ref. 6).
2. The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 5.5243913821672628e+000 with an estimated absolute error of
0.00e+000.
2D modification of an example by L.N.Trefethen (see ref. 7),
f(x)=exp(x).
'''
return np.exp(x + y)
@staticmethod
def runge(x, y):
''' Bivariate Runge function: as 1D complex function is analytic
in a neighborhood of [-1; 1] but not throughout the complex plane.
The value of the definite integral on the square [-1,1] x [-1,1],
up to machine precision, is 0.597388947274307 (see ref. 6).
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 5.9738894727430725e-001 with an estimated absolute error of
0.00e+000.
2D modification of an example by L.N.Trefethen (see ref. 7),
f(x)=1/(1+16*x^2).
'''
return 1. / (1 + 16 * (x**2 + y**2))
@staticmethod
def abs_cubed(x, y):
'''Low regular function.
The value of the definite integral on the square [-1,1] x [-1,1],
up to machine precision, is 2.508723139534059 (see ref. 6).
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 2.5087231395340579e+000 with an estimated absolute error of
0.00e+000.
2D modification of an example by L.N.Trefethen (see ref. 7),
f(x)=abs(x)^3.
'''
return (x**2 + y**2)**(3 / 2)
@staticmethod
def gauss(x, y):
'''Bivariate gaussian: smooth function.
The value of the definite integral on the square [-1,1] x [-1,1],
up to machine precision, is 2.230985141404135 (see ref. 6).
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 500,
is 2.2309851414041333e+000 with an estimated absolute error of
2.66e-015.
2D modification of an example by L.N.Trefethen (see ref. 7),
f(x)=exp(-x^2).
'''
return np.exp(-x**2 - y**2)
@staticmethod
def exp_inv(x, y):
'''Bivariate example stemming from a 1D C-infinity function.
The value of the definite integral on the square [-1,1] x [-1,1],
up to machine precision, is 0.853358758654305 (see ref. 6).
The value of the definite integral on the square [-1,1] x [-1,1],
obtained using a Padua Points cubature formula of degree 2000,
is 8.5335875865430544e-001 with an estimated absolute error of
3.11e-015.
2D modification of an example by L.N.Trefethen (see ref. 7),
f(x)=exp(-1/x^2).
'''
arg_z = (x**2 + y**2)
# Avoid cases in which "arg_z=0", setting only in those instances
# "arg_z=eps".
arg_z = arg_z + (1 - np.abs(np.sign(arg_z))) * 1.e-100
arg_z = 1. / arg_z
return np.exp(-arg_z)
def __call__(self, x, y, i=0):
s = self
test_function = [s.franke, s.half_sphere, s.poly_degree20, s.exp_fun1,
s.exp_fun100, s.cos30, s.constant, s.exp_xy, s.runge,
s.abs_cubed, s.gauss, s.exp_inv]
return test_function[i](x, y)
example_functions = _ExampleFunctions()
def _find_m(n):
ix = np.r_[1:(n + 1) * (n + 2):2]
if np.mod(n, 2) == 0:
n2 = n // 2
offset = np.array([[0, 1] * n2 + [0, ]] * (n2 + 1))
ix = ix - offset.ravel(order='F')
return ix
def padua_points(n, domain=(-1, 1, -1, 1)):
''' Return Padua points
Parameters
----------
n : scalar integer
interpolation degree
domain : vector [a,b,c,d]
defining the rectangle [a,b] x [c,d]. (default domain = (-1,1,-1,1))
Returns
-------
pad : array of shape (2 x (n+1)*(n+2)/2) such that
(pad[0,:], pad[1,: ]) defines the Padua points in the domain
rectangle [a,b] x [c,d].
or
X1,Y1,X2,Y2 : arrays
Two subgrids X1,Y1 and X2,Y2 defining the Padua points
-------------------------------------------------------------------------------
'''
a, b, c, d = domain
t0 = [np.pi] if n == 0 else np.linspace(0, np.pi, n + 1)
t1 = np.linspace(0, np.pi, n + 2)
zn = map_to_interval(np.cos(t0), a, b)
zn1 = map_to_interval(np.cos(t1), c, d)
Pad1, Pad2 = np.meshgrid(zn, zn1)
ix = _find_m(n)
return np.vstack((Pad1.ravel(order='F')[ix],
Pad2.ravel(order='F')[ix]))
def error_estimate(C0f):
''' Return interpolation error estimate from Padua coefficients
'''
n = C0f.shape[1]
C0f2 = np.fliplr(C0f)
errest = sum(np.abs(np.diag(C0f2)))
if (n >= 1):
errest = errest + sum(np.abs(np.diag(C0f2, -1)))
if (n >= 2):
errest = errest + sum(np.abs(np.diag(C0f2, -2)))
return 2 * errest
def padua_fit(Pad, fun, *args):
'''
Computes the Chebyshevs coefficients
so that f(x, y) can be approximated by:
f(x, y) = sum cjk*Tjk(x, y)
Parameters
----------
Pad : array-like
Padua points, as computed with padua_points function.
fun : function to be interpolated in the form
fun(x, y, *args), where *args are optional arguments for fun.
Returns
-------
coefficents: coefficient matrix
abs_err : interpolation error estimate
Example
------
>>> import numpy as np
>>> import wafo.padua as wp
>>> domain = [0, 1, 0, 1]
>>> a, b, c, d = domain
>>> points = wp.padua_points(21, domain)
>>> C0f, abs_error = wp.padua_fit(points, wp.example_functions.franke)
>>> x1 = np.linspace(a, b, 100)
>>> x2 = np.linspace(c, d, 101)
>>> val = wp.padua_val(x1, x2, C0f, domain, use_meshgrid=True)
>>> X1, X2 = np.meshgrid(x1, x2)
>>> true_val = wp.example_functions.franke(X1, X2)
>>> np.allclose(val, true_val, atol=10*abs_error)
True
>>> np.allclose(np.abs(val-true_val).max(), 0.0073174614275738296)
True
>>> np.allclose(abs_error, 0.0022486904061664046)
True
import matplotlib.pyplot as plt
plt.contour(x1, x2, val)
'''
N = np.shape(Pad)[1]
# recover the degree n from N = (n+1)(n+2)/2
n = int(round(-3 + np.sqrt(1 + 8 * N)) / 2)
C0f = fun(Pad[0], Pad[1], *args)
if (n > 0):
ix = _find_m(n)
GfT = np.zeros((n + 2) * (n + 1))
GfT[ix] = C0f * 2 / (n * (n + 1))
GfT = GfT.reshape(n + 1, n + 2)
GfT = GfT.T
GfT[0] = GfT[0] / 2
GfT[n + 1] = GfT[n + 1] / 2
GfT[:, 0] = GfT[:, 0] / 2
GfT[:, n] = GfT[:, n] / 2
Gf = GfT.T
# compute the interpolation coefficient matrix C0f by FFT
Gfhat = np.real(fft(Gf, 2 * n, axis=0))
Gfhathat = np.real(fft(Gfhat[:n + 1, :], 2 * (n + 1), axis=1))
C0f = 2 * Gfhathat[:, 0:n + 1]
C0f[0] = C0f[0, :] / np.sqrt(2)
C0f[:, 0] = C0f[:, 0] / np.sqrt(2)
C0f = np.fliplr(np.triu(np.fliplr(C0f)))
C0f[n] = C0f[n] / 2
return C0f, error_estimate(C0f)
def paduavals2coefs(f):
m = len(f)
n = int(round(-1.5 + np.sqrt(.25 + 2 * m)))
x = padua_points(n)
idx = _find_m(n)
w = 0 * x[0] + 1. / (n * (n + 1))
idx1 = np.all(np.abs(x) == 1, axis=0)
w[idx1] = .5 * w[idx1]
idx2 = np.all(np.abs(x) != 1, axis=0)
w[idx2] = 2 * w[idx2]
G = np.zeros(idx.max() + 1)
G[idx] = 4 * w * f
use_dct = 100 < n
if use_dct:
C = np.rot90(dct(dct(G.T).T)) # , axis=1)
else:
t1 = np.r_[0:n + 1].reshape(-1, 1)
Tn1 = np.cos(t1 * t1.T * np.pi / n)
t2 = np.r_[0:n + 2].reshape(-1, 1)
Tn2 = np.cos(t2 * t2.T * np.pi / (n + 1))
C = np.dot(Tn2, np.dot(G, Tn1))
C[0] = .5 * C[0]
C[:, 1] = .5 * C[:, 1]
C[0, -1] = .5 * C[0, -1]
del C[-1]
# Take upper-left triangular part:
return np.fliplr(np.triu(np.fliplr(C)))
# C = triu(C(:,end:-1:1));
# C = C(:,end:-1:1);
# TODO: padua_fit2 does not work correctly yet.
def padua_fit2(Pad, fun, *args):
# N = np.shape(Pad)[1]
# recover the degree n from N = (n+1)(n+2)/2
# _n = int(round(-3 + np.sqrt(1 + 8 * N)) / 2)
C0f = fun(Pad[0], Pad[1], *args)
return paduavals2coefs(C0f)
def _compute_moments(n):
k = np.r_[0:n:2]
mom = 2 * np.sqrt(2) / (1 - k ** 2)
mom[0] = 2
return mom
def padua_cubature(coefficients, domain=(-1, 1, -1, 1)):
'''
Compute the integral through the coefficient matrix.
'''
n = coefficients.shape[1]
mom = _compute_moments(n)
M1, M2 = np.meshgrid(mom, mom)
M = M1 * M2
C0fM = coefficients[0:n:2, 0:n:2] * M
a, b, c, d = domain
integral = (b - a) * (d - c) * C0fM.sum() / 4
return integral
def padua_val(X, Y, coefficients, domain=(-1, 1, -1, 1), use_meshgrid=False):
'''
Evaluate polynomial in padua form at X, Y.
Evaluate the interpolation polynomial defined through its coefficient
matrix coefficients at the target points X(:,1),X(:,2) or at the
meshgrid(X1,X2)
Parameters
----------
X, Y: array-like
evaluation points.
coefficients : array-like
coefficient matrix
domain : a vector [a,b,c,d]
defining the rectangle [a,b] x [c,d]
use_meshgrid: bool
If True interpolate at the points meshgrid(X, Y)
Returns
-------
fxy : array-like
evaluation of the interpolation polynomial at the target points
'''
def transform(tn, x, a, b):
xn = map_from_interval(x, a, b).clip(min=-1, max=1).reshape(1, -1)
tx = np.cos(tn * np.arccos(xn)) * np.sqrt(2)
tx[0] = 1
return tx
X, Y = np.atleast_1d(X, Y)
original_shape = X.shape
a, b, c, d = domain
n = np.shape(coefficients)[1]
tn = np.r_[0:n][:, None]
tx1 = transform(tn, X.ravel(), a, b)
tx2 = transform(tn, Y.ravel(), c, d)
if use_meshgrid: # eval on meshgrid points
return np.dot(tx1.T, np.dot(coefficients, tx2)).T
# scattered points
val = np.sum(np.dot(tx1.T, coefficients) * tx2.T, axis=1)
return val.reshape(original_shape)
if __name__ == '__main__':
from wafo.testing import test_docstrings
test_docstrings(__file__)

@ -1,18 +0,0 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 25 14:55:34 2015
@author: dave
"""
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('wafo', parent_package, top_path)
config.add_subpackage('source')
config.make_config_py()
return config
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())

@ -1,2 +0,0 @@
from wafo.sg_filter._core import * # pylint: disable=wildcard-import
from wafo.sg_filter import demos

File diff suppressed because one or more lines are too long

@ -1,488 +0,0 @@
import numpy as np
from scipy.sparse.linalg import expm
from scipy.signal import medfilt
from wafo.plotbackend import plotbackend as plt
from wafo.sg_filter._core import (SavitzkyGolay, smoothn, Kalman,
HodrickPrescott, HampelFilter)
def demo_savitzky_on_noisy_chirp():
"""
Example
-------
>>> demo_savitzky_on_noisy_chirp()
>>> plt.close()
"""
plt.figure(figsize=(7, 12))
# generate chirp signal
tvec = np.arange(0, 6.28, .02)
true_signal = np.sin(tvec * (2.0 + tvec))
true_d_signal = (2 + tvec) * np.cos(tvec * (2.0 + tvec))
# add noise to signal
noise = np.random.normal(size=true_signal.shape)
signal = true_signal + .15 * noise
# plot signal
plt.subplot(311)
plt.plot(signal)
plt.title('signal')
# smooth and plot signal
plt.subplot(312)
savgol = SavitzkyGolay(n=8, degree=4)
s_signal = savgol.smooth(signal)
s2 = smoothn(signal, robust=True)
plt.plot(s_signal)
plt.plot(s2)
plt.plot(true_signal, 'r--')
plt.title('smoothed signal')
# smooth derivative of signal and plot it
plt.subplot(313)
savgol1 = SavitzkyGolay(n=8, degree=1, diff_order=1)
dt = tvec[1] - tvec[0]
d_signal = savgol1.smooth(signal) / dt
plt.plot(d_signal)
plt.plot(true_d_signal, 'r--')
plt.title('smoothed derivative of signal')
def demo_kalman_voltimeter():
"""
Example
-------
>>> demo_kalman_voltimeter()
>>> plt.close()
"""
V0 = 12
h = np.atleast_2d(1) # voltimeter measure the voltage itself
q = 1e-9 # variance of process noise as the car operates
r = 0.05 ** 2 # variance of measurement error
b = 0 # no system input
u = 0 # no system input
filt = Kalman(R=r, A=1, Q=q, H=h, B=b)
# Generate random voltages and watch the filter operate.
n = 50
truth = np.random.randn(n) * np.sqrt(q) + V0
z = truth + np.random.randn(n) * np.sqrt(r) # measurement
x = np.zeros(n)
for i, zi in enumerate(z):
x[i] = filt(zi, u) # perform a Kalman filter iteration
_hz = plt.plot(z, 'r.', label='observations')
# a-posteriori state estimates:
_hx = plt.plot(x, 'b-', label='Kalman output')
_ht = plt.plot(truth, 'g-', label='true voltage')
plt.legend()
plt.title('Automobile Voltimeter Example')
def lti_disc(F, L=None, Q=None, dt=1):
"""LTI_DISC Discretize LTI ODE with Gaussian Noise.
Syntax:
[A,Q] = lti_disc(F,L,Qc,dt)
In:
F - NxN Feedback matrix
L - NxL Noise effect matrix (optional, default identity)
Qc - LxL Diagonal Spectral Density (optional, default zeros)
dt - Time Step (optional, default 1)
Out:
A - Transition matrix
Q - Discrete Process Covariance
Description:
Discretize LTI ODE with Gaussian Noise. The original
ODE model is in form
dx/dt = F x + L w, w ~ N(0,Qc)
Result of discretization is the model
x[k] = A x[k-1] + q, q ~ N(0,Q)
Which can be used for integrating the model
exactly over time steps, which are multiples
of dt.
"""
n = np.shape(F)[0]
if L is None:
L = np.eye(n)
if Q is None:
Q = np.zeros((n, n))
# Closed form integration of transition matrix
A = expm(F * dt)
# Closed form integration of covariance
# by matrix fraction decomposition
Phi = np.vstack((np.hstack((F, np.dot(np.dot(L, Q), L.T))),
np.hstack((np.zeros((n, n)), -F.T))))
AB = np.dot(expm(Phi * dt), np.vstack((np.zeros((n, n)), np.eye(n))))
# Q = AB[:n, :] / AB[n:(2 * n), :]
Q = np.linalg.solve(AB[n:(2 * n), :].T, AB[:n, :].T)
return A, Q
def demo_kalman_sine():
"""Kalman Filter demonstration with sine signal.
Example
-------
>>> demo_kalman_sine()
>>> plt.close()
"""
sd = 0.5
dt = 0.1
w = 1
T = np.arange(0, 30 + dt / 2, dt)
n = len(T)
X = 3 * np.sin(w * T)
Y = X + sd * np.random.randn(n)
''' Initialize KF to values
x = 0
dx/dt = 0
with great uncertainty in derivative
'''
M = np.zeros((2, 1))
P = np.diag([0.1, 2])
R = sd ** 2
H = np.atleast_2d([1, 0])
q = 0.1
F = np.atleast_2d([[0, 1],
[0, 0]])
A, Q = lti_disc(F, L=None, Q=np.diag([0, q]), dt=dt)
# Track and animate
m = M.shape[0]
_MM = np.zeros((m, n))
_PP = np.zeros((m, m, n))
'''In this demonstration we estimate a stationary sine signal from noisy
measurements by using the classical Kalman filter.'
'''
filt = Kalman(R=R, x=M, P=P, A=A, Q=Q, H=H, B=0)
# Generate random voltages and watch the filter operate.
# n = 50
# truth = np.random.randn(n) * np.sqrt(q) + V0
# z = truth + np.random.randn(n) * np.sqrt(r) # measurement
truth = X
z = Y
x = np.zeros((n, m))
for i, zi in enumerate(z):
x[i] = np.ravel(filt(zi, u=0))
_hz = plt.plot(z, 'r.', label='observations')
# a-posteriori state estimates:
_hx = plt.plot(x[:, 0], 'b-', label='Kalman output')
_ht = plt.plot(truth, 'g-', label='true voltage')
plt.legend()
plt.title('Automobile Voltimeter Example')
# for k in range(m):
# [M,P] = kf_predict(M,P,A,Q);
# [M,P] = kf_update(M,P,Y(k),H,R);
#
# MM(:,k) = M;
# PP(:,:,k) = P;
#
# %
# % Animate
# %
# if rem(k,10)==1
# plot(T,X,'b--',...
# T,Y,'ro',...
# T(k),M(1),'k*',...
# T(1:k),MM(1,1:k),'k-');
# legend('Real signal','Measurements','Latest estimate',
# 'Filtered estimate')
# title('Estimating a noisy sine signal with Kalman filter.');
# drawnow;
#
# pause;
# end
# end
#
# clc;
# disp('In this demonstration we estimate a stationary sine signal '
# 'from noisy measurements by using the classical Kalman filter.');
# disp(' ');
# disp('The filtering results are now displayed sequantially for 10 time '
# 'step at a time.');
# disp(' ');
# disp('<push any key to see the filtered and smoothed results together>')
# pause;
# %
# % Apply Kalman smoother
# %
# SM = rts_smooth(MM,PP,A,Q);
# plot(T,X,'b--',...
# T,MM(1,:),'k-',...
# T,SM(1,:),'r-');
# legend('Real signal','Filtered estimate','Smoothed estimate')
# title('Filtered and smoothed estimate of the original signal');
#
# clc;
# disp('The filtered and smoothed estimates of the signal are now '
# 'displayed.')
# disp(' ');
# disp('RMS errors:');
# %
# % Errors
# %
# fprintf('KF = %.3f\nRTS = %.3f\n',...
# sqrt(mean((MM(1,:)-X(1,:)).^2)),...
# sqrt(mean((SM(1,:)-X(1,:)).^2)));
def demo_hampel():
"""
Example
-------
>>> demo_hampel()
>>> plt.close()
"""
randint = np.random.randint
Y = 5000 + np.random.randn(1000)
outliers = randint(0, 1000, size=(10,))
Y[outliers] = Y[outliers] + randint(1000, size=(10,))
YY, res = HampelFilter(dx=3, t=3, fulloutput=True)(Y)
YY1, res1 = HampelFilter(dx=1, t=3, adaptive=0.1, fulloutput=True)(Y)
YY2, res2 = HampelFilter(dx=3, t=0, fulloutput=True)(Y) # median
plt.figure(1)
plot_hampel(Y, YY, res)
plt.title('Standard HampelFilter')
plt.figure(2)
plot_hampel(Y, YY1, res1)
plt.title('Adaptive HampelFilter')
plt.figure(3)
plot_hampel(Y, YY2, res2)
plt.title('Median filter')
def plot_hampel(Y, YY, res):
X = np.arange(len(YY))
plt.plot(X, Y, 'b.') # Original Data
plt.plot(X, YY, 'r') # Hampel Filtered Data
plt.plot(X, res['Y0'], 'b--') # Nominal Data
plt.plot(X, res['LB'], 'r--') # Lower Bounds on Hampel Filter
plt.plot(X, res['UB'], 'r--') # Upper Bounds on Hampel Filter
i = res['outliers']
plt.plot(X[i], Y[i], 'ks') # Identified Outliers
def demo_tide_filter():
"""
Example
-------
>>> demo_tide_filter()
>>> plt.close()
"""
# import statsmodels.api as sa
import wafo.spectrum.models as sm
sd = 10
Sj = sm.Jonswap(Hm0=4. * sd)
S = Sj.tospecdata()
q = (0.1 * sd) ** 2 # variance of process noise s the car operates
r = (100 * sd) ** 2 # variance of measurement error
b = 0 # no system input
u = 0 # no system input
from scipy.signal import butter, filtfilt, lfilter_zi # lfilter,
freq_tide = 1. / (12 * 60 * 60)
freq_wave = 1. / 10
freq_filt = freq_wave / 10
dt = 1.
freq = 1. / dt
fn = (freq / 2)
P = 10 * np.diag([1, 0.01])
R = r
H = np.atleast_2d([1, 0])
F = np.atleast_2d([[0, 1],
[0, 0]])
A, Q = lti_disc(F, L=None, Q=np.diag([0, q]), dt=dt)
t = np.arange(0, 60 * 12, 1. / freq)
w = 2 * np.pi * freq # 1 Hz
tide = 100 * np.sin(freq_tide * w * t + 2 * np.pi / 4) + 100
y = tide + S.sim(len(t), dt=1. / freq)[:, 1].ravel()
# lowess = sa.nonparametric.lowess
# y2 = lowess(y, t, frac=0.5)[:,1]
filt = Kalman(R=R, x=np.array([[tide[0]], [0]]), P=P, A=A, Q=Q, H=H, B=b)
filt2 = Kalman(R=R, x=np.array([[tide[0]], [0]]), P=P, A=A, Q=Q, H=H, B=b)
# y = tide + 0.5 * np.sin(freq_wave * w * t)
# Butterworth filter
b, a = butter(9, (freq_filt / fn), btype='low')
# y2 = [lowess(y[max(i-60,0):i + 1], t[max(i-60,0):i + 1], frac=.3)[-1,1]
# for i in range(len(y))]
# y2 = [lfilter(b, a, y[:i + 1])[i] for i in range(len(y))]
# y3 = filtfilt(b, a, y[:16]).tolist() + [filtfilt(b, a, y[:i + 1])[i]
# for i in range(16, len(y))]
# y0 = medfilt(y, 41)
_zi = lfilter_zi(b, a)
# y2 = lfilter(b, a, y)#, zi=y[0]*zi) # standard filter
y3 = filtfilt(b, a, y) # filter with phase shift correction
y4 = []
y5 = []
for _i, j in enumerate(y):
tmp = np.ravel(filt(j, u=u))
tmp = np.ravel(filt2(tmp[0], u=u))
# if i==0:
# print(filt.x)
# print(filt2.x)
y4.append(tmp[0])
y5.append(tmp[1])
_y0 = medfilt(y4, 41)
# print(filt.P)
# plot
plt.plot(t, y, 'r.-', linewidth=2, label='raw data')
# plt.plot(t, y2, 'b.-', linewidth=2, label='lowess @ %g Hz' % freq_filt)
# plt.plot(t, y2, 'b.-', linewidth=2, label='filter @ %g Hz' % freq_filt)
plt.plot(t, y3, 'g.-', linewidth=2, label='filtfilt @ %g Hz' % freq_filt)
plt.plot(t, y4, 'k.-', linewidth=2, label='kalman')
# plt.plot(t, y5, 'k.', linewidth=2, label='kalman2')
plt.plot(t, tide, 'y-', linewidth=2, label='True tide')
plt.legend(frameon=False, fontsize=14)
plt.xlabel("Time [s]")
plt.ylabel("Amplitude")
def demo_savitzky_on_exponential():
"""
Example
-------
>>> demo_savitzky_on_exponential()
>>> plt.close()
"""
t = np.linspace(-4, 4, 500)
y = np.exp(-t ** 2) + np.random.normal(0, 0.05, np.shape(t))
n = 11
ysg = SavitzkyGolay(n, degree=1, diff_order=0)(y)
plt.plot(t, y, t, ysg, '--')
def demo_smoothn_on_1d_cos():
"""
Example
-------
>>> demo_smoothn_on_1d_cos()
>>> plt.close()
"""
x = np.linspace(0, 100, 2 ** 8)
y = np.cos(x / 10) + (x / 50) ** 2 + np.random.randn(np.size(x)) / 10
y[np.r_[70, 75, 80]] = np.array([5.5, 5, 6])
z = smoothn(y) # Regular smoothing
zr = smoothn(y, robust=True) # Robust smoothing
_h0 = plt.subplot(121),
_h = plt.plot(x, y, 'r.', x, z, 'k', linewidth=2)
plt.title('Regular smoothing')
plt.subplot(122)
plt.plot(x, y, 'r.', x, zr, 'k', linewidth=2)
plt.title('Robust smoothing')
def demo_smoothn_on_2d_exp_sin():
"""
Example
-------
>>> demo_smoothn_on_2d_exp_sin()
>>> plt.close()
"""
xp = np.arange(0, 1, 0.02) # np.r_[0:1:0.02]
[x, y] = np.meshgrid(xp, xp)
f = np.exp(x + y) + np.sin((x - 2 * y) * 3)
fn = f + np.random.randn(*f.shape) * 0.5
_fs, s = smoothn(fn, fulloutput=True)
fs2 = smoothn(fn, s=2 * s)
_h = plt.subplot(131),
_h = plt.contourf(xp, xp, fn)
_h = plt.subplot(132),
_h = plt.contourf(xp, xp, fs2)
_h = plt.subplot(133),
_h = plt.contourf(xp, xp, f)
def _cardioid(n=1000):
t = np.linspace(0, 2 * np.pi, n)
x0 = 2 * np.cos(t) * (1 - np.cos(t))
y0 = 2 * np.sin(t) * (1 - np.cos(t))
x = x0 + np.random.randn(x0.size) * 0.1
y = y0 + np.random.randn(y0.size) * 0.1
return x, y, x0, y0
def demo_smoothn_on_cardioid():
"""
Example
-------
>>> demo_smoothn_on_cardioid()
>>> plt.close()
"""
x, y, x0, y0 = _cardioid()
z = smoothn(x + 1j * y, robust=False)
plt.plot(x0, y0, 'y',
x, y, 'r.',
np.real(z), np.imag(z), 'k', linewidth=2)
def demo_hodrick_on_cardioid():
"""
Example
-------
>>> demo_hodrick_on_cardioid()
>>> plt.close()
"""
x, y, x0, y0 = _cardioid()
smooth = HodrickPrescott(w=20000)
# smooth = HampelFilter(adaptive=50)
xs, ys = smooth(x), smooth(y)
plt.plot(x0, y0, 'y',
x, y, 'r.',
xs, ys, 'k', linewidth=2)
if __name__ == '__main__':
from wafo.testing import test_docstrings
test_docstrings(__file__)
# demo_savitzky_on_noisy_chirp()
# plt.show('hold') # show plot
# demo_kalman_sine()
# demo_tide_filter()
# demo_hampel()
# demo_kalman_voltimeter()
# demo_savitzky_on_exponential()
# plt.figure(1)
# demo_hodrick_on_cardioid()
# plt.figure(2)
# # demo_smoothn_on_1d_cos()
# demo_smoothn_on_cardioid()
# plt.show('hold')

@ -1,11 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dummy conftest.py for wafo.
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
https://pytest.org/latest/plugins.html
"""
from __future__ import print_function, absolute_import, division
import pytest # @UnusedImport

File diff suppressed because one or more lines are too long

@ -1,25 +0,0 @@
"""
f2py c_library.pyf c_functions.c -c
See also http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW
"""
import os
import sys
from wafo.f2py_tools import f2py_call_str
def compile_all():
f2py_call = f2py_call_str()
print '=' * 75
print 'compiling c_codes'
print '=' * 75
compile_format = f2py_call + ' %s %s -c'
pyfs = ('c_library.pyf',)
files = ('c_functions.c',)
for pyf, file_ in zip(pyfs, files):
os.system(compile_format % (pyf, file_))
if __name__ == '__main__':
compile_all()

@ -1,779 +0,0 @@
#include "math.h"
/*
* Install gfortran and run the following to build the module on windows:
* f2py c_library.pyf c_functions.c -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71
*/
/*
* findrfc.c -
*
* Returns indices to RFC turningpoints of a vector
* of turningpoints
*
* 1998 by Per Andreas Brodtkorb.
*/
void findrfc(double *y1,double hmin, int *ind, int n,int *info) {
double xminus, xplus, Tpl, Tmi, *y, Tstart;
int i, j, ix=0, NC, iy;
info[0] = 0;
if (*(y1+0)> *(y1+1)){
/* if first is a max , ignore the first max*/
y=&(*(y1+1));
NC=floor((n-1)/2);
Tstart=1;
}
else {
y=y1;
NC=floor(n/2);
Tstart=0;
}
if (NC<1){
return; /* No RFC cycles*/
}
if (( *(y+0) > *(y+1)) && ( *(y+1) > *(y+2)) ){
info[0] = -1;
return; /*This is not a sequence of turningpoints, exit */
}
if ((*(y+0) < *(y+1)) && (*(y+1)< *(y+2))){
info[0]=-1;
return; /*This is not a sequence of turningpoints, exit */
}
for (i=0; i<NC; i++) {
Tmi=Tstart+2*i;
Tpl=Tstart+2*i+2;
xminus=*(y+2*i);
xplus=*(y+2*i+2);
if(i!=0){
j=i-1;
while((j>=0) && (*(y+2*j+1)<=*(y+2*i+1))){
if( (*(y+2*j)<xminus) ){
xminus=*(y+2*j);
Tmi=Tstart+2*j;
} /*if */
j--;
} /*while j*/
} /*if i */
if ( xminus >= xplus){
if ( (*(y+2*i+1)-xminus) >= hmin){
*(ind+ix)=Tmi;
ix++;
*(ind+ix)=(Tstart+2*i+1);
ix++;
} /*if*/
goto L180;
}
j=i+1;
while((j<NC) ) {
if (*(y+2*j+1) >= *(y+2*i+1)) goto L170;
if( (*(y+2*j+2) <= xplus) ){
xplus=*(y+2*j+2);
Tpl=(Tstart+2*j+2);
}/*if*/
j++;
} /*while*/
if ( (*(y+2*i+1)-xminus) >= hmin) {
*(ind+ix)=Tmi;
ix++;
*(ind+ix)=(Tstart+2*i+1);
ix++;
} /*if*/
goto L180;
L170:
if (xplus <= xminus ) {
if ( (*(y+2*i+1)-xminus) >= hmin){
*(ind+ix)=Tmi;
ix++;
*(ind+ix)=(Tstart+2*i+1);
ix++;
} /*if*/
/*goto L180;*/
}
else{
if ( (*(y+2*i+1)-xplus) >= hmin) {
*(ind+ix)=(Tstart+2*i+1);
ix++;
*(ind+ix)=Tpl;
ix++;
} /*if*/
} /*elseif*/
L180:
iy=i;
} /* for i */
info[0] = ix;
return ;
}
/*
* findcross.c -
*
* Returns indices to level v crossings of argument vector
*
* 1998 by Per Andreas Brodtkorb. last modified 23.06-98
*/
void findcross(double *y, double v, int *ind, int n, int *info)
{ int i,start, ix=0,dcross=0;
start=0;
if ( y[0]< v){
dcross=-1; /* first is a up-crossing*/
}
else if ( y[0]> v){
dcross=1; /* first is a down-crossing*/
}
else if ( y[0]== v){
/* Find out what type of crossing we have next time.. */
for (i=1; i<n; i++) {
start=i;
if ( y[i]< v){
ind[ix] = i-1; /* first crossing is a down crossing*/
ix++;
dcross=-1; /* The next crossing is a up-crossing*/
goto L120;
}
else if ( y[i]> v){
ind[ix] = i-1; /* first crossing is a up-crossing*/
ix++;
dcross=1; /*The next crossing is a down-crossing*/
goto L120;
}
}
}
L120:
for (i=start; i<n-1; i++) {
if (( (dcross==-1) && (y[i]<=v) && (y[i+1] > v) ) || ((dcross==1 ) && (y[i]>=v) && (y[i+1] < v) ) ) {
ind[ix] = i;
ix++;
dcross=-dcross;
}
}
info[0] = ix;
return;
}
/*
* DISUFQ Is an internal function to spec2nlsdat
*
* CALL: disufq(rvec,ivec,rA,iA, w,kw,h,g,nmin,nmax,m,n)
*
* rvec, ivec = real and imaginary parts of the resultant (size m X n).
* rA, iA = real and imaginary parts of the amplitudes (size m X n).
* w = vector with angular frequencies (w>=0)
* kw = vector with wavenumbers (kw>=0)
* h = water depth (h >=0)
* g = constant acceleration of gravity
* nmin = minimum index where rA(:,nmin) and iA(:,nmin) is
* greater than zero.
* nmax = maximum index where rA(:,nmax) and iA(:,nmax) is
* greater than zero.
* m = size(rA,1),size(iA,1)
* n = size(rA,2),size(iA,2), or size(rvec,2),size(ivec,2)
*
* DISUFQ returns the summation of difference frequency and sum
* frequency effects in the vector vec = rvec +sqrt(-1)*ivec.
* The 2'nd order contribution to the Stokes wave is then calculated by
* a simple 1D Fourier transform, real(FFT(vec)).
*
* Install gfortran and run the following to build the module:
* f2py diffsumfunq.pyf disufq1.c -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71
*
* by Per Andreas Brodtkorb 15.08.2001
* revised pab 14.03.2002, 01.05.2002 22.07.2002, oct 2008
*/
void disufq(double *rvec, double *ivec,
double *rA, double *iA,
double *w, double *kw,
double h, double g,
int nmin, int nmax,
int m, int n)
{
double Epij, Edij;
double tmp1, tmp2, tmp3, tmp4, kfact;
double w1, w2, kw1, kw2, Cg;
double rrA, iiA, riA, irA;
int i,jy,ix,iz1,iv1,ixi,jyi;
//int iz2, iv2;
//Initialize rvec and ivec to zero
for (ix=0;ix<n*m;ix++) {
rvec[ix] = 0.0;
ivec[ix] = 0.0;
}
// kfact is set to 2 in order to exploit the symmetry.
// If you set kfact to 1, you must uncomment all statements
// including the expressions: rvec[iz2], rvec[iv2], ivec[iz2] and ivec[iv2].
kfact = 2.0;
if (h>10000){ /* deep water /Inifinite water depth */
for (ix = nmin-1;ix<nmax;ix++) {
ixi = ix*m;
iz1 = 2*ixi;
//iz2 = n*m-ixi;
kw1 = kw[ix];
Epij = kw1;
for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal
tmp1 = kfact*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*riA*Epij;
rvec[iz1] += tmp1;
ivec[iz1] += tmp2;
//rvec[iz2] += tmp1;
//ivec[iz2] -= tmp2;
//iz2++;
/// Difference frequency effects are zero along the diagonal
/// and are thus not contributing to the mean.
}
for (jy = ix+1;jy<nmax;jy++){
kw2 = kw[jy];
Epij = 0.5*(kw2 + kw1);
Edij = -0.5*(kw2 - kw1);
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
jyi = jy*m;
iz1 = ixi+jyi;
iv1 = jyi-ixi;
//iz2 = (n*m-iz1);
//iv2 = (n*m-iv1);
for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij;
rvec[iz1] += tmp1;///rvec[i][ix+jy] += tmp1;
ivec[iz1] += tmp2;///ivec[i][ix+jy] += tmp2;
//rvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1;
//ivec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] -= tmp2;
// iz2++;
/* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij;
rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
ivec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2;
//rvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1;
//ivec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2;
//iv2++;
}
}
}
}
else{ /* Finite water depth */
for (ix = nmin-1;ix<nmax;ix++) {
kw1 = kw[ix];
w1 = w[ix];
tmp1 = tanh(kw1*h);
/// Cg, wave group velocity
Cg = 0.5*g*(tmp1 + kw1*h*(1.0- tmp1*tmp1))/w1; /// OK
tmp1 = 0.5*g*(kw1/w1)*(kw1/w1);
tmp2 = 0.5*w1*w1/g;
tmp3 = g*kw1/(w1*Cg);
if (kw1*h<300.0){
tmp4 = kw1/sinh(2.0*kw1*h);
}
else{ // To ensure sinh does not overflow.
tmp4 = 0.0;
}
// Difference frequency effects finite water depth
Edij = (tmp1-tmp2+tmp3)/(1.0-g*h/(Cg*Cg))-tmp4; /// OK
// Sum frequency effects finite water depth
Epij = (3.0*(tmp1-tmp2)/(1.0-tmp1/kw1*tanh(2.0*kw1*h))+3.0*tmp2-tmp1); /// OK
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
iz1 = 2*ixi;
//iz2 = n*m-ixi;
for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal
rvec[iz1] += kfact*(rrA-iiA)*Epij;
ivec[iz1] += kfact*2.0*riA*Epij;
//rvec[iz2] += kfact*(rrA-iiA)*Epij;
//ivec[iz2] -= kfact*2.0*riA*Epij;
//iz2++;
/// Difference frequency effects along the diagonal
/// are only contributing to the mean
rvec[i] += 2.0*(rrA+iiA)*Edij;
}
for (jy = ix+1;jy<nmax;jy++) {
// w1 = w[ix];
// kw1 = kw[ix];
w2 = w[jy];
kw2 = kw[jy];
tmp1 = g*(kw1/w1)*(kw2/w2);
tmp2 = 0.5/g*(w1*w1+w2*w2+w1*w2);
tmp3 = 0.5*g*(w1*kw2*kw2+w2*kw1*kw1)/(w1*w2*(w1+w2));
tmp4 = (1-g*(kw1+kw2)/(w1+w2)/(w1+w2)*tanh((kw1+kw2)*h));
Epij = (tmp1-tmp2+tmp3)/tmp4+tmp2-0.5*tmp1; /* OK */
tmp2 = 0.5/g*(w1*w1+w2*w2-w1*w2); /*OK*/
tmp3 = -0.5*g*(w1*kw2*kw2-w2*kw1*kw1)/(w1*w2*(w1-w2));
tmp4 = (1.0-g*(kw1-kw2)/(w1-w2)/(w1-w2)*tanh((kw1-kw2)*h));
Edij = (tmp1-tmp2+tmp3)/tmp4+tmp2-0.5*tmp1; /* OK */
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
jyi = jy*m;
iz1 = ixi+jyi;
iv1 = jyi-ixi;
// iz2 = (n*m-iz1);
// iv2 = n*m-iv1;
for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij;
rvec[iz1] += tmp1;///rvec[i][jy+ix] += tmp1;
ivec[iz1] += tmp2;///ivec[i][jy+ix] += tmp2;
//rvec[iz2] += tmp1;///rvec[i][n*m-(jy+ix)] += tmp1;
//ivec[iz2] -= tmp2;///ivec[i][n*m-(jy+ix)] -= tmp2;
//iz2++;
/* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij;
rvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
ivec[iv1] += tmp2;///ivec[i][jy-ix] -= tmp2;
//rvec[iv2] += tmp1;
//ivec[iv2] -= tmp2;
//iv2++;
}
}
}
}
//return i;
}
/*
* DISUFQ2 Is an internal function to spec2nlsdat
*
* CALL: disufq2(rsvec,isvec,rdvec,idvec,rA,iA, w,kw,h,g,nmin,nmax,m,n)
*
* rsvec, isvec = real and imaginary parts of the sum frequency
* effects (size m X n).
* rdvec, idvec = real and imaginary parts of the difference frequency
* effects (size m X n).
* rA, iA = real and imaginary parts of the amplitudes (size m X n).
* w = vector with angular frequencies (w>=0)
* kw = vector with wavenumbers (kw>=0)
* h = water depth (h >=0)
* g = constant acceleration of gravity
* nmin = minimum index where rA(:,nmin) and iA(:,nmin) is
* greater than zero.
* nmax = maximum index where rA(:,nmax) and iA(:,nmax) is
* greater than zero.
* m = size(rA,1),size(iA,1)
* n = size(rA,2),size(iA,2), or size(rvec,2),size(ivec,2)
*
* DISUFQ2 returns the summation of sum and difference frequency
* frequency effects in the vectors svec = rsvec +sqrt(-1)*isvec and
* dvec = rdvec +sqrt(-1)*idvec.
* The 2'nd order contribution to the Stokes wave is then calculated by
* a simple 1D Fourier transform, real(FFT(svec+dvec)).
*
*
* This is a MEX-file for MATLAB.
* by Per Andreas Brodtkorb 15.08.2001
* revised pab 14.03.2002, 01.05.2002
*/
void disufq2(double *rsvec, double *isvec,
double *rdvec, double *idvec,
double *rA, double *iA,
double *w, double *kw,
double h, double g,
int nmin, int nmax,
int m, int n)
{
double Epij, Edij;
double tmp1, tmp2, tmp3, tmp4, kfact;
double w1, w2, kw1, kw2, Cg;
double rrA, iiA, riA, irA;
int i,jy,ix,iz1,iv1,ixi,jyi;
//int iz2,iv2
//Initialize rvec and ivec to zero
for (ix=0;ix<n*m;ix++) {
rsvec[ix] = 0.0;
isvec[ix] = 0.0;
rdvec[ix] = 0.0;
idvec[ix] = 0.0;
}
// kfact is set to 2 in order to exploit the symmetry.
// If you set kfact to 1, you must uncomment all statements
// including the expressions: rvec[iz2], rvec[iv2], ivec[iz2] and ivec[iv2].
kfact = 2.0;
if (h>10000){ /* deep water /Inifinite water depth */
for (ix = nmin-1;ix<nmax;ix++) {
ixi = ix*m;
iz1 = 2*ixi;
//iz2 = n*m-ixi;
kw1 = kw[ix];
Epij = kw1;
for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal
tmp1 = kfact*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*riA*Epij;
rsvec[iz1] += tmp1;
isvec[iz1] += tmp2;
//rsvec[iz2] += tmp1;
//isvec[iz2] -= tmp2;
//iz2++;
/// Difference frequency effects are zero along the diagonal
/// and are thus not contributing to the mean.
}
for (jy = ix+1;jy<nmax;jy++){
kw2 = kw[jy];
Epij = 0.5*(kw2 + kw1);
Edij = -0.5*(kw2 - kw1);
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
jyi = jy*m;
iz1 = ixi+jyi;
iv1 = jyi-ixi;
//iz2 = (n*m-iz1);
//iv2 = (n*m-iv1);
for (i = 0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij;
rsvec[iz1] += tmp1; ///rvec[i][ix+jy] += tmp1;
isvec[iz1] += tmp2; ///ivec[i][ix+jy] += tmp2;
//rsvec[iz2] += tmp1;///rvec[i][n*m-(ix+jy)] += tmp1;
//isvec[iz2] -= tmp2;///ivec[i][n*m-(ix+jy)] += tmp2;
//iz2++;
/* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij;
rdvec[iv1] += tmp1;///rvec[i][jy-ix] += tmp1;
idvec[iv1] += tmp2;///ivec[i][jy-ix] += tmp2;
//rdvec[iv2] += tmp1;///rvec[i][n*m-(jy-ix)] += tmp1;
//idvec[iv2] -= tmp2;///ivec[i][n*m-(jy-ix)] -= tmp2;
// iv2++;
}
}
}
}
else{ /* Finite water depth */
for (ix = nmin-1;ix<nmax;ix++) {
kw1 = kw[ix];
w1 = w[ix];
tmp1 = tanh(kw1*h);
/// Cg, wave group velocity
Cg = 0.5*g*(tmp1 + kw1*h*(1.0- tmp1*tmp1))/w1; /// OK
tmp1 = 0.5*g*(kw1/w1)*(kw1/w1);
tmp2 = 0.5*w1*w1/g;
tmp3 = g*kw1/(w1*Cg);
if (kw1*h<300.0){
tmp4 = kw1/sinh(2.0*kw1*h);
}
else{ // To ensure sinh does not overflow.
tmp4 = 0.0;
}
// Difference frequency effects finite water depth
Edij = (tmp1-tmp2+tmp3)/(1.0-g*h/(Cg*Cg))-tmp4; /// OK
// Sum frequency effects finite water depth
Epij = (3.0*(tmp1-tmp2)/(1.0-tmp1/kw1*tanh(2.0*kw1*h))+3.0*tmp2-tmp1); /// OK
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
iz1 = 2*ixi;
//iz2 = n*m-ixi;
for (i=0;i<m;i++,ixi++,iz1++) {
rrA = rA[ixi]*rA[ixi]; ///
iiA = iA[ixi]*iA[ixi]; ///
riA = rA[ixi]*iA[ixi]; ///
/// Sum frequency effects along the diagonal
rsvec[iz1] += kfact*(rrA-iiA)*Epij;
isvec[iz1] += kfact*2.0*riA*Epij;
//rsvec[iz2] += kfact*(rrA-iiA)*Epij;
//isvec[iz2] -= kfact*2.0*riA*Epij;
/// Difference frequency effects along the diagonal
/// are only contributing to the mean
//printf(" %f \n",2.0*(rrA+iiA)*Edij);
rdvec[i] += 2.0*(rrA+iiA)*Edij;
}
for (jy = ix+1;jy<nmax;jy++) {
// w1 = w[ix];
// kw1 = kw[ix];
w2 = w[jy];
kw2 = kw[jy];
tmp1 = g*(kw1/w1)*(kw2/w2);
tmp2 = 0.5/g*(w1*w1+w2*w2+w1*w2);
tmp3 = 0.5*g*(w1*kw2*kw2+w2*kw1*kw1)/(w1*w2*(w1+w2));
tmp4 = (1-g*(kw1+kw2)/(w1+w2)/(w1+w2)*tanh((kw1+kw2)*h));
Epij = (tmp1-tmp2+tmp3)/tmp4+tmp2-0.5*tmp1; /* OK */
tmp2 = 0.5/g*(w1*w1+w2*w2-w1*w2); /*OK*/
tmp3 = -0.5*g*(w1*kw2*kw2-w2*kw1*kw1)/(w1*w2*(w1-w2));
tmp4 = (1.0-g*(kw1-kw2)/(w1-w2)/(w1-w2)*tanh((kw1-kw2)*h));
Edij = (tmp1-tmp2+tmp3)/tmp4+tmp2-0.5*tmp1; /* OK */
//printf("Edij = %f Epij = %f \n", Edij,Epij);
ixi = ix*m;
jyi = jy*m;
iz1 = ixi+jyi;
iv1 = jyi-ixi;
// iz2 = (n*m-iz1);
// iv2 = (n*m-iv1);
for (i=0;i<m;i++,ixi++,jyi++,iz1++,iv1++) {
rrA = rA[ixi]*rA[jyi]; ///rrA = rA[i][ix]*rA[i][jy];
iiA = iA[ixi]*iA[jyi]; ///iiA = iA[i][ix]*iA[i][jy];
riA = rA[ixi]*iA[jyi]; ///riA = rA[i][ix]*iA[i][jy];
irA = iA[ixi]*rA[jyi]; ///irA = iA[i][ix]*rA[i][jy];
/* Sum frequency effects */
tmp1 = kfact*2.0*(rrA-iiA)*Epij;
tmp2 = kfact*2.0*(riA+irA)*Epij;
rsvec[iz1] += tmp1;///rsvec[i][jy+ix] += tmp1;
isvec[iz1] += tmp2;///isvec[i][jy+ix] += tmp2;
//rsvec[iz2] += tmp1;///rsvec[i][n*m-(jy+ix)] += tmp1;
//isvec[iz2] -= tmp2;///isvec[i][n*m-(jy-ix)] += tmp2;
//iz2++;
/* Difference frequency effects */
tmp1 = kfact*2.0*(rrA+iiA)*Edij;
tmp2 = kfact*2.0*(riA-irA)*Edij;
rdvec[iv1] += tmp1;
idvec[iv1] += tmp2;
//rdvec[iv2] += tmp1;
//idvec[iv2] -= tmp2;
// iv2++;
}
}
}
}
// return i;
}
/* ++++++++++ BEGIN RF3 [ampl ampl_mean nr_of_cycle] */
/* ++++++++++ Rain flow without time analysis */
//By Adam Nieslony
//Visit the MATLAB Central File Exchange for latest version
//http://www.mathworks.com/matlabcentral/fileexchange/3026
void findrfc3_astm(double *array_ext, double *array_out, int n, int *nout) {
double *pr, *po, a[16384], ampl, mean;
int tot_num, index, j, cNr1, cNr2;
tot_num = n;
// pointers to the first element of the arrays
pr = &array_ext[0];
po = &array_out[0];
// The original rainflow counting by Nieslony, unchanged
j = -1;
cNr1 = 1;
for (index=0; index<tot_num; index++) {
a[++j]=*pr++;
while ( (j >= 2) && (fabs(a[j-1]-a[j-2]) <= fabs(a[j]-a[j-1])) ) {
ampl=fabs( (a[j-1]-a[j-2])/2 );
switch(j) {
case 0: { break; }
case 1: { break; }
case 2: {
mean=(a[0]+a[1])/2;
a[0]=a[1];
a[1]=a[2];
j=1;
if (ampl > 0) {
*po++=ampl;
*po++=mean;
*po++=0.50;
}
break;
}
default: {
mean=(a[j-1]+a[j-2])/2;
a[j-2]=a[j];
j=j-2;
if (ampl > 0) {
*po++=ampl;
*po++=mean;
*po++=1.00;
cNr1++;
}
break;
}
}
}
}
cNr2 = 1;
for (index=0; index<j; index++) {
ampl=fabs(a[index]-a[index+1])/2;
mean=(a[index]+a[index+1])/2;
if (ampl > 0){
*po++=ampl;
*po++=mean;
*po++=0.50;
cNr2++;
}
}
// array of ints nout is outputted
nout[0] = cNr1;
nout[1] = cNr2;
}
/* ++++++++++ END RF3 */
// ++ BEGIN RF5 [ampl ampl_mean nr_of_cycle cycle_begin_time cycle_period_time]
/* ++++++++++ Rain flow with time analysis */
//By Adam Nieslony
//Visit the MATLAB Central File Exchange for latest version
//http://www.mathworks.com/matlabcentral/fileexchange/3026
void
findrfc5_astm(double *array_ext, double *array_t, double *array_out, int n, int *nout) {
double *pr, *pt, *po, a[16384], t[16384], ampl, mean, period, atime;
int tot_num, index, j, cNr1, cNr2;
// tot_num = mxGetM(array_ext) * mxGetN(array_ext);
tot_num = n;
// pointers to the first element of the arrays
pr = &array_ext[0];
pt = &array_t[0];
po = &array_out[0];
// array_out = mxCreateDoubleMatrix(5, tot_num-1, mxREAL);
// The original rainflow counting by Nieslony, unchanged
j = -1;
cNr1 = 1;
for (index=0; index<tot_num; index++) {
a[++j]=*pr++;
t[j]=*pt++;
while ( (j >= 2) && (fabs(a[j-1]-a[j-2]) <= fabs(a[j]-a[j-1])) ) {
ampl=fabs( (a[j-1]-a[j-2])/2 );
switch(j)
{
case 0: { break; }
case 1: { break; }
case 2: {
mean=(a[0]+a[1])/2;
period=(t[1]-t[0])*2;
atime=t[0];
a[0]=a[1];
a[1]=a[2];
t[0]=t[1];
t[1]=t[2];
j=1;
if (ampl > 0) {
*po++=ampl;
*po++=mean;
*po++=0.50;
*po++=atime;
*po++=period;
}
break;
}
default: {
mean=(a[j-1]+a[j-2])/2;
period=(t[j-1]-t[j-2])*2;
atime=t[j-2];
a[j-2]=a[j];
t[j-2]=t[j];
j=j-2;
if (ampl > 0) {
*po++=ampl;
*po++=mean;
*po++=1.00;
*po++=atime;
*po++=period;
cNr1++;
}
break;
}
}
}
}
cNr2 = 1;
for (index=0; index<j; index++) {
ampl=fabs(a[index]-a[index+1])/2;
mean=(a[index]+a[index+1])/2;
period=(t[index+1]-t[index])*2;
atime=t[index];
if (ampl > 0){
*po++=ampl;
*po++=mean;
*po++=0.50;
*po++=atime;
*po++=period;
cNr2++;
}
}
// /* free the memeory !!!*/
// mxSetN(array_out, tot_num - cNr);
nout[0] = cNr1;
nout[1] = cNr2;
}
/* ++++++++++ END RF5 */

@ -1,24 +0,0 @@
Copyright (c) 2003, Adam Niesłony
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

@ -1,86 +0,0 @@
! File c_code.pyf
python module c_library
interface
subroutine findrfc(y1, hmin, ind, n, info)
intent(c) findrfc ! findrfc is a C function
intent(c) ! all findrfc arguments are considered as C based
integer intent(hide), depend(y1) :: n=len(y1)
double precision dimension(n), intent(in) :: y1 ! input array
double precision intent(in) :: hmin
integer dimension(n), intent(out) :: ind ! output array,
integer dimension(1), intent(out) :: info
end subroutine findrfc
subroutine findcross(y, v, ind, n, info)
intent(c) findcross ! findcross is a C function
intent(c) ! all findcross arguments are considered as C based
integer intent(hide), depend(y) :: n=len(y)
double precision dimension(n), intent(in) :: y ! input array
double precision intent(in) :: v
integer dimension(n), intent(out) :: ind ! output array,
integer dimension(1),intent(out) :: info
end subroutine findcross
subroutine disufq(rvec, ivec, rA, iA, w, kw, h, g,nmin,nmax, m, n)
intent(c) disufq ! disufq is a C function
intent(c) ! all disufq arguments are considered as C based
!integer intent(hide), depend(rA),check(n*m==len(iA)) :: n=len(rA)/m
!integer intent(hide), depend(rA), check(m==shape(iA,1)) :: m=shape(rA,1)
double precision dimension(n*m), intent(in) :: rA, iA ! input array
double precision dimension(n/2+1), intent(in) :: w, kw ! input array
double precision intent(in) :: h, g
integer intent(in) :: nmin, nmax
double precision dimension(n*m), intent(out) :: rvec, ivec ! output array,
end subroutine disufq
subroutine disufq2(rsvec, isvec,rdvec, idvec, rA, iA, w, kw, h, g,nmin,nmax, m, n)
intent(c) disufq2 ! disufq2 is a C function
intent(c) ! all disufq2 arguments are considered as C based
!integer intent(hide), depend(rA),check(n*m==len(iA)) :: n=len(rA)/m
!integer intent(hide), depend(rA), check(m==shape(iA,1)) :: m=shape(rA,1)
double precision dimension(n*m), intent(in) :: rA, iA ! input array
double precision dimension(n/2+1), intent(in) :: w, kw ! input array
double precision intent(in) :: h, g
integer intent(in) :: nmin, nmax
double precision dimension(n*m), intent(out) :: rsvec, isvec, rdvec, idvec ! output array,
end subroutine disufq2
! ===== START NIESLONY RAINFLOW FUNCTIONS
! RAINFLOW Revision: 1.1
! by Adam Nieslony, 2009
subroutine findrfc3_astm(array_ext, array_out, n, nout)
intent(c) findrfc3_astm ! rf3 is a C function
intent(c) ! all rf3 arguments are
! considered as C based
! n is the length of the input array array_ext
integer intent(hide), depend(array_ext) :: n=len(array_ext)
! of input array x
double precision intent(in) :: array_ext(n)
! the output array
double precision intent(out) :: array_out(n,3)
! nout array, to output additional ints
integer dimension(2), intent(out) :: nout
end subroutine findrfc3_astm
subroutine findrfc5_astm(array_ext, array_t, array_out, n, nout)
intent(c) findrfc5_astm ! rf5 is a C function
intent(c) ! all rf5 arguments are
! considered as C based
! n is the length of the input array array_ext
integer intent(hide), depend(array_ext) :: n=len(array_ext)
! of input array x
double precision intent(in) :: array_ext(n), array_t(n)
! the output array
double precision intent(out) :: array_out(n,5)
! nout array, to output additional ints
integer dimension(2), intent(out) :: nout
end subroutine findrfc5_astm
! ===== END NIESLONY RAINFLOW FUNCTIONS
end interface
end python module c_library

File diff suppressed because it is too large Load Diff

@ -1,18 +0,0 @@
'''
python setup.py build_src build_ext --inplace
See also http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW
'''
# File setup.py
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('', parent_package, top_path)
config.add_extension('c_library',
sources=['c_library.pyf', 'c_functions.c'])
return config
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())

@ -1,450 +0,0 @@
PROGRAM sp2Acdf1
C***********************************************************************
C This program computes upper and lower bounds for: *
C *
C density of T_i, for Ac <=h, in a gaussian process i.e. *
C *
C half wavelength (up-crossing to downcrossing) for crests <h *
C or half wavelength (down-crossing to upcrossing) for trough >h *
C I.R. 27 Dec. 1999 *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansrup
double precision, dimension(:,:),allocatable :: ansrlo
double precision, dimension(: ),allocatable :: ex,CY
double precision, dimension(:,:),allocatable :: xc,fxind
double precision, dimension(: ),allocatable :: h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,ph,def,seed1,seed_size,icy
integer ::it1,it2,status
double precision :: ds,dT ! lag spacing for covariances
! f90 sp2Acdf1.f rind50.f
CALL INIT_LEVELS(U,def,Ntime,Nstart,NIT,speed,Nx,dT)
!print *,'U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
if (abs(def).GT.1) THEN
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
!CALL INIT_AMPLITUDES(h,def,Nx)
endif
allocate(h(1:Nx))
CALL INIT_AMPLITUDES(h,def,Nx)
CALL INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
NI=4; Nd=2
Nc=3; Mb=2
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY(1:Nx))
do icy=1,Nx
CY(icy)=exp(-0.5*h(icy)*h(icy)/100)/(10*sqrt(twopi))
enddo
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate BIG'
end if
allocate(ex(1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate ex'
end if
allocate(ansrup(1:Ntime,1:Nx))
allocate(ansrlo(1:Ntime,1:Nx))
ansrup=0.d0
ansrlo=0.d0
allocate(fxind(1:Nx,1:2))
fxind=0.d0 !this is not needed
allocate(xc(1:Nc,1:Nx))
allocate(a_up(Mb,NI-1))
allocate(a_lo(Mb,NI-1))
a_up=0.d0
a_lo=0.d0
xc(1,1:Nx)=h(1:Nx)
xc(2,1:Nx)=u
xc(3,1:Nx)=u
if (def.GT.0) then
a_up(1,1)=0.d0
a_lo(1,1)=u
a_up(1,2)=XdInf
a_lo(1,3)=-XdInf
a_up(2,1)=1.d0
else
a_up(1,1)=u
a_lo(1,1)=0.d0
a_lo(1,2)=-XdInf
a_up(1,3)= XdInf
a_lo(2,1)=1.d0
endif
!print *,'Nstart',Nstart
Nstart=MAX(3,Nstart)
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
!print *,'loop starts'
do Ntd=Nstart,Ntime
Ntdc=Ntd+Nc
ex=0.d0
BIG=0.d0
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),Ntd,-1,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
!print *,'test',fxind/CY(1:Nx)
do icy=1,Nx
ansrup(Ntd,icy)=fxind(icy,1)*CC/CY(icy)
ansrlo(Ntd,icy)=fxind(icy,2)*CC/CY(icy)
enddo
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
if((Nx.gt.4).or.NIT.gt.4) print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 300
300 open (unit=11, file='dens.out', STATUS='unknown')
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansrup(ts,ph),ansrlo(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 continue
deallocate(BIG)
deallocate(ex)
deallocate(fxind)
deallocate(ansrup)
deallocate(ansrlo)
deallocate(xc)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
if (allocated(R3)) then
deallocate(R3)
deallocate(R4)
deallocate(h)
ENDIF
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,def,Ntime,Nstart,NIT,speed,Nx,dT)
IMPLICIT NONE
integer, intent(out):: def,Ntime,Nstart,NIT,speed,Nx
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) def
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
if (abs(def).GT.1) then
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
else
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
endif
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,def,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: def
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
!if (def.LT.0) THEN
! H=-H
!endif
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime,def
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
if (abs(def).GT.1) then
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(4)
close(5)
endif
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,shft,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! For ts>1:
! X(t2)..X(ts),..X(tn-1) X''(ts) X'(t1) X'(tn) X(ts) X(t1) X(tn) X'(ts)
! = [Xt Xd Xc]
!
! For ts<=1:
! X(t2)..,..X(tn-1) X'(t1) X'(tn) Y X(t1) X(tn)
! = [Xt Xd Xc]
!Add Y Condition : Y=h
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
if (ts.LE.1) THEN
Ntd1=tn
N=Ntd1+Nc;
shft=0 ! def=1 want only crest period Tc
else
Ntd1=tn+1
N=Ntd1+4
shft=1 ! def=2 or 3 want Tc Ac or Tcf, Ac
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1+shft) = 0.d0 !cov(X(ti+1),Y)
BIG(i ,Ntd1+2+shft) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+3+shft) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X' (t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X' (tn))
enddo
!call echo(big(1:tn,1:tn),tn)
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
!cov(Xc)
!print *,'t'
BIG(Ntd1+1+shft,Ntd1+1+shft) = 100.d0!100.d0 ! cov(Y,Y)
BIG(Ntd1+1+shft,Ntd1+2+shft) = 0.d0
BIG(Ntd1+1+shft,Ntd1+3+shft) = 0.d0
BIG(Ntd1+2+shft,Ntd1+2+shft) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+2+shft,Ntd1+3+shft) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+3+shft,Ntd1+3+shft) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1+shft) = 0.d0 !cov(X'(tn),Y)
BIG(Ntd1 ,Ntd1+2+shft) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+3+shft) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+1+shft) = 0.d0 !cov(X'(t1),Y)
BIG(Ntd1-1,Ntd1+2+shft) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+3+shft) =-R1(tn) !cov(X'(t1),X(tn))
!call echo(big(1:N,1:N),N)
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
!call echo(big(1:N,1:N),N)
enddo
!if (tn.eq.3) then
!do j=1,N
! do i=j,N
! print *,'test',j,i,BIG(j,i)
! enddo
!call echo(big(1:N,1:N),N)
!enddo
!endif
!call echo(big(1:N,1:N),N)
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2Acdf1

@ -1,356 +0,0 @@
PROGRAM sp2mM1
C***********************************************************************************
C Computes upper lower bounds for density of maximum and the following minimum *
C***********************************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansrup
double precision, dimension(:,:),allocatable :: ansrlo
double precision, dimension(: ),allocatable :: ex,h
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(:,:),allocatable :: fxind
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,seed1,seed_size
integer :: status,i,j,ij,Nx1
double precision :: ds,dT ! lag spacing for covariances
! f90 sp2AmM1.f rind52.f
CALL INIT_LEVELS(Ntime,Nstart,NIT,speed,Nx1,dT)
Nx=Nx1*(Nx1-1)/2
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
allocate(h(1:Nx1))
CALL INIT_AMPLITUDES(h,Nx1)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y= X'(t2)...X'(tn-1)||X''(t1) X''(tn)||X(t1) X(tn) X'(t1) X'(tn) !!
! = [ Xt Xd Xc ] !!
! !!
! Nt=tn-2, Nd=2, Nc=4 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! !!
! There are 3 ( NI=4) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] Y(i)<0. !!
! (indI(2)=Nt) ; for i\in (indI(2)+1,indI(3)], Y(i)<0 (deriv. X''(t1)) !!
! (indI(3)=Nt+1); for i\in (indI(3)+1,indI(4)], Y(i)>0 (deriv. X''(tn)) !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=4; Nd=2
Nc=4; Mb=1
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(R4(1))
XtInf=10.d0*SQRT(-R2(1))
! normalizing constant
CC=TWOPI*SQRT(-R2(1)/R4(1))
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate BIG'
end if
allocate(ex(1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate ex'
end if
allocate(ansrup(1:Nx1,1:Nx1))
ansrup=0.d0
allocate(ansrlo(1:Nx1,1:Nx1))
ansrlo=0.d0
allocate(fxind(1:Nx,1:2))
fxind=0.d0 !this is not needed
allocate(xc(1:Nc,1:Nx))
allocate(a_up(Mb,NI-1))
allocate(a_lo(Mb,NI-1))
a_up=0.d0
a_lo=0.d0
ij=0
do i=2,Nx1
do j=1,i-1
ij=ij+1
xc(1,ij)=h(i)
xc(2,ij)=h(j)
enddo
enddo
xc(3,1:Nx)=0.d0
xc(4,1:Nx)=0.d0
a_lo(1,1)=-Xtinf
a_lo(1,2)=-XdInf
a_up(1,3)=+XdInf
Nstart=MAX(2,Nstart)
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
do Ntd=Nstart,Ntime
Ntdc=Ntd+Nc
ex=0.d0
BIG=0.d0
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),Ntd,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
ij=0
do i=2,Nx1
do j=1,i-1
ij=ij+1
ansrup(i,j)=ansrup(i,j)+fxind(ij,1)*CC*dt
ansrlo(i,j)=ansrlo(i,j)+fxind(ij,2)*CC*dt
enddo
enddo
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 300
300 open (unit=11, file='dens.out', STATUS='unknown')
do i=1,Nx1
do j=1,Nx1
write(11,*) ansrup(i,j),ansrlo(i,j)
enddo
enddo
close(11)
900 continue
deallocate(BIG)
deallocate(ex)
deallocate(fxind)
deallocate(ansrup)
deallocate(ansrlo)
deallocate(xc)
deallocate(R0)
deallocate(R1)
deallocate(R2)
deallocate(R3)
deallocate(R4)
deallocate(h)
if (allocated(COV) ) then
deallocate(COV)
endif
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (Ntime,Nstart,NIT,speed,Nx,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,Nstart,NIT,speed,Nx
double precision ,intent(out) :: dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
READ (14,*) dT
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(1)
close(2)
close(3)
close(3)
close(5)
return
END SUBROUTINE INIT_COVARIANCES
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn
integer :: i,j,N
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X(t1),X(tn),X'(t1),X'(tn)
! = [ Xt | Xd | Xc ]
!
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
N=tn+4
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = -R2(j-i+1) ! cov(X'(ti+1),X'(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,tn+1) = R1(i+1) !cov(X'(ti+1),X(t1))
BIG(tn-1-i ,tn+2) = -R1(i+1) !cov(X'(ti+1),X(tn))
BIG(i ,tn+3) = -R2(i+1) !cov(X'(ti+1),X'(t1))
BIG(tn-1-i ,tn+4) = -R2(i+1) !cov(X'(ti+1),X'(tn))
!Cov(Xt,Xd)
BIG(i,tn-1) = R3(i+1) !cov(X'(ti+1),X''(t1))
BIG(tn-1-i,tn) =-R3(i+1) !cov(X'(ti+1),X''(tn))
enddo
!cov(Xd)
BIG(tn-1 ,tn-1 ) = R4(1)
BIG(tn-1,tn ) = R4(tn) !cov(X''(t1),X''(tn))
BIG(tn ,tn ) = R4(1)
!cov(Xc)
BIG(tn+1,tn+1) = R0(1) ! cov(X(t1),X(t1))
BIG(tn+1,tn+2) = R0(tn) ! cov(X(t1),X(tn))
BIG(tn+1,tn+3) = 0.d0 ! cov(X(t1),X'(t1))
BIG(tn+1,tn+4) = R1(tn) ! cov(X(t1),X'(tn))
BIG(tn+2,tn+2) = R0(1) ! cov(X(tn),X(tn))
BIG(tn+2,tn+3) =-R1(tn) ! cov(X(tn),X'(t1))
BIG(tn+2,tn+4) = 0.d0 ! cov(X(tn),X'(tn))
BIG(tn+3,tn+3) =-R2(1) ! cov(X'(t1),X'(t1))
BIG(tn+3,tn+4) =-R2(tn) ! cov(X'(t1),X'(tn))
BIG(tn+4,tn+4) =-R2(1) ! cov(X'(tn),X'(tn))
!Xc=X(t1),X(tn),X'(t1),X'(tn)
!Xd=X''(t1),X''(tn)
!cov(Xd,Xc)
BIG(tn-1 ,tn+1) = R2(1) !cov(X''(t1),X(t1))
BIG(tn-1 ,tn+2) = R2(tn) !cov(X''(t1),X(tn))
BIG(tn-1 ,tn+3) = 0.d0 !cov(X''(t1),X'(t1))
BIG(tn-1 ,tn+4) = R3(tn) !cov(X''(t1),X'(tn))
BIG(tn ,tn+1) = R2(tn) !cov(X''(tn),X(t1))
BIG(tn ,tn+2) = R2(1) !cov(X''(tn),X(tn))
BIG(tn ,tn+3) =-R3(tn) !cov(X''(tn),X'(t1))
BIG(tn ,tn+4) = 0.d0 !cov(X''(tn),X'(tn))
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
RETURN
END SUBROUTINE COV_INPUT
END PROGRAM sp2mM1

@ -1,504 +0,0 @@
PROGRAM sp2tccpdf1
C***********************************************************************
C This program computes upper and lower bounds for the: *
C *
C density of T= T_1+T_2 in a gaussian process i.e. *
C *
C wavelengthes for crests <h1 and troughs >h2 *
C *
C Sylvie and Igor 7 dec. 1999 *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
& NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansrup
double precision, dimension(:,:),allocatable :: ansrlo
double precision, dimension(: ),allocatable :: ex,CY1,CY2
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(:,:),allocatable ::fxind
double precision, dimension(: ),allocatable :: h1,h2
double precision, dimension(: ),allocatable :: hh1,hh2
double precision, dimension(: ),allocatable :: R0,R1,R2
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Ntime,N0,tn,ts,speed,ph,seed1,seed_size,Nx1,Nx2
integer :: icy,icy2
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -g2 -C -automatic -o ~/WAT/V4/sp2tthpdf.exe rind48.f sp2tthpdf.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../sp2tthpdf.exe rind48.f sp2tthpdf.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
!print *,'U,Ntime,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,Ntime,NIT,speed,SCIS,seed1,Nx,dT
!Nx1=1
!Nx2=1
Nx=Nx1*Nx2
!print *,'NN',Nx1,Nx2,Nx
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(h1(1:Nx1))
allocate(h2(1:Nx2))
CALL INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2)
allocate(hh1(1:Nx))
allocate(hh2(1:Nx))
!h transformation
do icy=1,Nx1
do icy2=1,Nx2
hh1((icy-1)*Nx2+icy2)=h1(icy);
hh2((icy-1)*Nx2+icy2)=h2(icy2);
enddo
enddo
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!h1(1)=XtInf
!h2(1)=XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY1(1:Nx))
allocate(CY2(1:Nx))
do icy=1,Nx
CY1(icy)=exp(-0.5*hh1(icy)*hh1(icy)/100)/(10*sqrt(twopi))
CY2(icy)=exp(-0.5*hh2(icy)*hh2(icy)/100)/(10*sqrt(twopi))
enddo
!print *,CY1
allocate(ansrup(1:Ntime,1:Nx))
allocate(ansrlo(1:Ntime,1:Nx))
ansrup=0.d0
ansrlo=0.d0
allocate(fxind(1:Nx,1:2))
!fxind=0.d0 this is not needed
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y={X(t2)..,X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)} !!
! = [Xt Xd Xc] !!
! !!
! Nt=tn-2, Nd=3, Nc=2+3 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! (Y1,Y2) dummy variables ind. of all other v. inputing h1,h2 into rindd !!
! !!
! There are 6 ( NI=7) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] u<Y(i)<h1 !!
! (indI(2)=ts-2); for i\in (indI(2),indI(2)], inf<Y(i)<inf (no restr.) !!
! (indI(3)=ts-1); for i\in (indI(3),indI(4)], h2 <Y(i)<u !!
! (indI(4)=Nt) ; for i\in (indI(4),indI(5)], Y(i)<0 (deriv. X'(ts)) !!
! (indI(5)=Nt+1); for i\in (indI(5),indI(6)], Y(i)>0 (deriv. X'(t1)) !!
! (indI(6)=Nt+2); for i\in (indI(6),indI(7)], Y(i)>0 (deriv. X'(tn)) !!
! (indI(7)=Nt+3); NI=7. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=7; Nd=3
Nc=5; Mb=3
allocate(a_up(1:Mb,1:(NI-1)))
allocate(a_lo(1:Mb,1:(NI-1)))
a_up=0.d0
a_lo=0.d0
allocate(BIG(1:(Ntime+Nc+1),1:(Ntime+Nc+1)))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:(Ntime+Nc+1)))
!print *,size(ex),Ntime
ex=0.d0
!print *,size(ex),ex
xc(1,1:Nx)=hh1(1:Nx)
xc(2,1:Nx)=hh2(1:Nx)
xc(3,1:Nx)=u
xc(4,1:Nx)=u
xc(5,1:Nx)=u
! upp- down- upp-crossings at t1,ts,tn
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(1,3)=u
a_lo(1,4)=-XdInf
a_up(1,5)= XdInf
a_up(1,6)= XdInf
a_up(2,1)=1.d0
a_lo(3,3)=1.d0 !signe a voir!!!!!!
! print *,a_up
! print *,a_lo
do tn=N0,Ntime,1
! do tn=Ntime,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
if (SCIS.gt.0) then
if (SCIS.EQ.2) then
Nj=max(Nt,0)
else
Nj=min(max(Nt-5, 0),0)
endif
endif
do ts=3,tn-2
!print *,'ts,tn' ,ts,tn,Ntdc
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2)!positive wave period
indI(2)=ts-2
indI(3)=ts-1
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
ds=dt
do icy=1,Nx
! ansr(tn,:)=ansr(tn,:)+fxind*CC*ds./(CY1.*CY2)
ansrup(tn,icy)=ansrup(tn,icy)+fxind(icy,1)*CC*ds
& /(CY1(icy)*CY2(icy))
ansrlo(tn,icy)=ansrlo(tn,icy)+fxind(icy,2)*CC*ds
& /(CY1(icy)*CY2(icy))
enddo
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime
enddo !tn
300 open (unit=11, file='dens.out', STATUS='unknown')
do ts=1,Ntime
do ph=1,Nx
!write(11,*) ansrup(ts,ph),ansrlo(ts,ph)
write(11,111) ansrup(ts,ph),ansrlo(ts,ph)
enddo
enddo
111 FORMAT(2x,F12.8,2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansrup)
deallocate(ansrlo)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
deallocate(h1)
deallocate(h2)
deallocate(hh1)
deallocate(hh2)
deallocate(a_up)
deallocate(a_lo)
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,N0,NIT,speed,Nx1,Nx2,SCIS,seed1
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) Ntime
READ (14,*) N0
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx1,Nx2
READ (14,*) dT
if (Ntime.lt.5) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h1,h2
integer, intent(in) :: Nx1,Nx2
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx1
READ (4,*) H1(ix)
enddo
do ix=1,Nx2
READ (4,*) H2(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
integer ,intent(in) :: tn,ts
integer :: i,j,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
!
! ||X(t2)..X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
Ntd1=tn+1
N=Ntd1+Nc
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1) = 0.d0 !cov(X(ti+1),Y1)
BIG(i ,Ntd1+2) = 0.d0 !cov(X(ti+1),Y2)
BIG(i ,Ntd1+4) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+5) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X'(t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X'(tn))
enddo
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
BIG(Ntd1-2,Ntd1-1) = -R2(ts) !cov(X'(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = -R2(1)
BIG(Ntd1-2,Ntd1 ) = -R2(tn+1-ts) !cov(X'(ts),X'(tn))
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = 100.d0 ! cov(Y1 Y1)
BIG(Ntd1+1,Ntd1+2) = 0.d0 ! cov(Y1 Y2)
BIG(Ntd1+1,Ntd1+3) = 0.d0 ! cov(Y1 X(ts))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(Y1 X(t1))
BIG(Ntd1+1,Ntd1+5) = 0.d0 ! cov(Y1 X(tn))
BIG(Ntd1+2,Ntd1+2) = 100.d0 ! cov(Y2 Y2)
BIG(Ntd1+2,Ntd1+3) = 0.d0 ! cov(Y2 X(ts))
BIG(Ntd1+2,Ntd1+4) = 0.d0 ! cov(Y2 X(t1))
BIG(Ntd1+2,Ntd1+5) = 0.d0 ! cov(Y2 X(tn))
BIG(Ntd1+3,Ntd1+3) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+3,Ntd1+4) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+3,Ntd1+5) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+4,Ntd1+4) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+4,Ntd1+5) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+5,Ntd1+5) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1) = 0.d0 !cov(X'(tn),Y1)
BIG(Ntd1 ,Ntd1+2) = 0.d0 !cov(X'(tn),Y2)
BIG(Ntd1-1 ,Ntd1+1) = 0.d0 !cov(X'(t1),Y1)
BIG(Ntd1-1 ,Ntd1+2) = 0.d0 !cov(X'(t1),Y2)
BIG(Ntd1-2 ,Ntd1+1) = 0.d0 !cov(X'(ts),Y1)
BIG(Ntd1-2 ,Ntd1+2) = 0.d0 !cov(X'(ts),Y2)
BIG(Ntd1 ,Ntd1+4) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+5) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+4) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+5) =-R1(tn) !cov(X'(t1),X(tn))
BIG(Ntd1 ,Ntd1+3) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+3) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+3) = 0.d0 !cov(X'(ts),X (ts)
BIG(Ntd1-2,Ntd1+4) = R1(ts) !cov(X'(ts),X (t1))
BIG(Ntd1-2,Ntd1+5) = -R1(tn+1-ts) !cov(X'(ts),X (tn))
do i=1,tn-2
j=abs(i+1-ts)
!cov(Xt,Xc)
BIG(i,Ntd1+3) = R0(j+1) !cov(X(ti+1),X(ts))
!Cov(Xt,Xd)
if ((i+1-ts).lt.0) then
BIG(i,Ntd1-2) = R1(j+1)
else !cov(X(ti+1),X'(ts))
BIG(i,Ntd1-2) = -R1(j+1)
endif
enddo
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2tccpdf1

@ -1,497 +0,0 @@
PROGRAM sp2tthpdf1
C***********************************************************************
C This program computes: *
C *
C density of T= T_1+T_2 in a gaussian process i.e. *
C *
C wavelengthes for crests <h1 and troughs >h2 *
C *
C Sylvie and Igor 7 dec. 1999 *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
& NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex,CY1,CY2
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h1,h2
double precision, dimension(: ),allocatable :: hh1,hh2
double precision, dimension(: ),allocatable :: R0,R1,R2
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Ntime,tn,ts,speed,ph,seed1,seed_size,Nx1,Nx2,N0
integer :: icy,icy2
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -g2 -C -automatic -o ~/WAT/V4/sp2tthpdf1.exe rind49.f sp2tthpdf1.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../sp2tthpdf.exe rind49.f sp2tthpdf1.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
!print *,'U,Ntime,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,Ntime,NIT,speed,SCIS,seed1,Nx,dT
!Nx1=1
!Nx2=1
Nx=Nx1*Nx2
!print *,'NN',Nx1,Nx2,Nx
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(h1(1:Nx1))
allocate(h2(1:Nx2))
CALL INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2)
allocate(hh1(1:Nx))
allocate(hh2(1:Nx))
!h transformation
do icy=1,Nx1
do icy2=1,Nx2
hh1((icy-1)*Nx2+icy2)=h1(icy);
hh2((icy-1)*Nx2+icy2)=h2(icy2);
enddo
enddo
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!h1(1)=XtInf
!h2(1)=XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY1(1:Nx))
allocate(CY2(1:Nx))
do icy=1,Nx
CY1(icy)=exp(-0.5*hh1(icy)*hh1(icy)/100)/(10*sqrt(twopi))
CY2(icy)=exp(-0.5*hh2(icy)*hh2(icy)/100)/(10*sqrt(twopi))
enddo
!print *,CY1
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
fxind=0.d0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y={X(t2)..,X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)} !!
! = [Xt Xd Xc] !!
! !!
! Nt=tn-2, Nd=3, Nc=2+3 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! (Y1,Y2) dummy variables ind. of all other v. inputing h1,h2 into rindd !!
! !!
! There are 6 ( NI=7) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] u<Y(i)<h1 !!
! (indI(2)=ts-2); for i\in (indI(2),indI(2)], inf<Y(i)<inf (no restr.) !!
! (indI(3)=ts-1); for i\in (indI(3),indI(4)], h2 <Y(i)<u !!
! (indI(4)=Nt) ; for i\in (indI(4),indI(5)], Y(i)<0 (deriv. X'(ts)) !!
! (indI(5)=Nt+1); for i\in (indI(5),indI(6)], Y(i)>0 (deriv. X'(t1)) !!
! (indI(6)=Nt+2); for i\in (indI(6),indI(7)], Y(i)>0 (deriv. X'(tn)) !!
! (indI(7)=Nt+3); NI=7. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=7; Nd=3
Nc=5; Mb=3
allocate(a_up(1:Mb,1:(NI-1)))
allocate(a_lo(1:Mb,1:(NI-1)))
a_up=0.d0
a_lo=0.d0
allocate(BIG(1:(Ntime+Nc+1),1:(Ntime+Nc+1)))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:(Ntime+Nc+1)))
!print *,size(ex),Ntime
ex=0.d0
!print *,size(ex),ex
xc(1,1:Nx)=hh1(1:Nx)
xc(2,1:Nx)=hh2(1:Nx)
xc(3,1:Nx)=u
xc(4,1:Nx)=u
xc(5,1:Nx)=u
! upp- down- upp-crossings at t1,ts,tn
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(1,3)=u
a_lo(1,4)=-XdInf
a_up(1,5)= XdInf
a_up(1,6)= XdInf
a_up(2,1)=1.d0
a_lo(3,3)=1.d0 !signe a voir!!!!!!
! print *,a_up
! print *,a_lo
do tn=N0,Ntime,1
! do tn=Ntime,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
if (SCIS.gt.0) then
if (SCIS.EQ.2) then
Nj=max(Nt,0)
else
Nj=min(max(Nt-5, 0),0)
endif
endif
do ts=3,tn-2
!print *,'ts,tn' ,ts,tn,Ntdc
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2)!positive wave period
indI(2)=ts-2
indI(3)=ts-1
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
ds=dt
do icy=1,Nx
! ansr(tn,:)=ansr(tn,:)+fxind*CC*ds./(CY1.*CY2)
ansr(tn,icy)=ansr(tn,icy)+fxind(icy)*CC*ds/(CY1(icy)*CY2(icy))
enddo
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime
enddo !tn
!print *,'ansr',ansr
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansr(ts,ph),hh1(ph),hh2(ph)
! write(11,111) ansr(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
deallocate(h1)
deallocate(h2)
deallocate(hh1)
deallocate(hh2)
deallocate(a_up)
deallocate(a_lo)
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,N0,NIT,speed,Nx1,Nx2,SCIS,seed1
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) Ntime
READ (14,*) N0
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx1,Nx2
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h1,h2
integer, intent(in) :: Nx1,Nx2
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx1
READ (4,*) H1(ix)
enddo
do ix=1,Nx2
READ (4,*) H2(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
integer ,intent(in) :: tn,ts
integer :: i,j,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
!
! ||X(t2)..X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
Ntd1=tn+1
N=Ntd1+Nc
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1) = 0.d0 !cov(X(ti+1),Y1)
BIG(i ,Ntd1+2) = 0.d0 !cov(X(ti+1),Y2)
BIG(i ,Ntd1+4) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+5) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X'(t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X'(tn))
enddo
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
BIG(Ntd1-2,Ntd1-1) = -R2(ts) !cov(X'(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = -R2(1)
BIG(Ntd1-2,Ntd1 ) = -R2(tn+1-ts) !cov(X'(ts),X'(tn))
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = 100.d0 ! cov(Y1 Y1)
BIG(Ntd1+1,Ntd1+2) = 0.d0 ! cov(Y1 Y2)
BIG(Ntd1+1,Ntd1+3) = 0.d0 ! cov(Y1 X(ts))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(Y1 X(t1))
BIG(Ntd1+1,Ntd1+5) = 0.d0 ! cov(Y1 X(tn))
BIG(Ntd1+2,Ntd1+2) = 100.d0 ! cov(Y2 Y2)
BIG(Ntd1+2,Ntd1+3) = 0.d0 ! cov(Y2 X(ts))
BIG(Ntd1+2,Ntd1+4) = 0.d0 ! cov(Y2 X(t1))
BIG(Ntd1+2,Ntd1+5) = 0.d0 ! cov(Y2 X(tn))
BIG(Ntd1+3,Ntd1+3) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+3,Ntd1+4) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+3,Ntd1+5) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+4,Ntd1+4) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+4,Ntd1+5) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+5,Ntd1+5) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1) = 0.d0 !cov(X'(tn),Y1)
BIG(Ntd1 ,Ntd1+2) = 0.d0 !cov(X'(tn),Y2)
BIG(Ntd1-1 ,Ntd1+1) = 0.d0 !cov(X'(t1),Y1)
BIG(Ntd1-1 ,Ntd1+2) = 0.d0 !cov(X'(t1),Y2)
BIG(Ntd1-2 ,Ntd1+1) = 0.d0 !cov(X'(ts),Y1)
BIG(Ntd1-2 ,Ntd1+2) = 0.d0 !cov(X'(ts),Y2)
BIG(Ntd1 ,Ntd1+4) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+5) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+4) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+5) =-R1(tn) !cov(X'(t1),X(tn))
BIG(Ntd1 ,Ntd1+3) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+3) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+3) = 0.d0 !cov(X'(ts),X (ts)
BIG(Ntd1-2,Ntd1+4) = R1(ts) !cov(X'(ts),X (t1))
BIG(Ntd1-2,Ntd1+5) = -R1(tn+1-ts) !cov(X'(ts),X (tn))
do i=1,tn-2
j=abs(i+1-ts)
!cov(Xt,Xc)
BIG(i,Ntd1+3) = R0(j+1) !cov(X(ti+1),X(ts))
!Cov(Xt,Xd)
if ((i+1-ts).lt.0) then
BIG(i,Ntd1-2) = R1(j+1)
else !cov(X(ti+1),X'(ts))
BIG(i,Ntd1-2) = -R1(j+1)
endif
enddo
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2tthpdf1

@ -1,445 +0,0 @@
PROGRAM sp2Acdf
C***********************************************************************
C This program computes: *
C *
C density of T_i, for Ac <=h, in a gaussian process i.e. *
C *
C half wavelength (up-crossing to downcrossing) for crests <h *
C or half wavelength (down-crossing to upcrossing) for trough >h *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex,CY
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,ph,def,seed1,seed_size,icy
integer ::it1,it2,status
double precision :: ds,dT ! lag spacing for covariances
! f90 sp2Acdf.f rind51.f
CALL INIT_LEVELS(U,def,Ntime,Nstart,NIT,speed,Nx,dT)
!print *,'U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
if (abs(def).GT.1) THEN
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
!CALL INIT_AMPLITUDES(h,def,Nx)
endif
allocate(h(1:Nx))
CALL INIT_AMPLITUDES(h,def,Nx)
CALL INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
NI=4; Nd=2
Nc=3; Mb=2
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY(1:Nx))
do icy=1,Nx
CY(icy)=exp(-0.5*h(icy)*h(icy)/100)/(10*sqrt(twopi))
enddo
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate BIG'
end if
allocate(ex(1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate ex'
end if
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
fxind=0.d0 !this is not needed
allocate(xc(1:Nc,1:Nx))
allocate(a_up(Mb,NI-1))
allocate(a_lo(Mb,NI-1))
a_up=0.d0
a_lo=0.d0
xc(1,1:Nx)=h(1:Nx)
xc(2,1:Nx)=u
xc(3,1:Nx)=u
if (def.GT.0) then
a_up(1,1)=0.d0
a_lo(1,1)=u
a_up(1,2)=XdInf
a_lo(1,3)=-XdInf
a_up(2,1)=1.d0
else
a_up(1,1)=u
a_lo(1,1)=0.d0
a_lo(1,2)=-XdInf
a_up(1,3)= XdInf
a_lo(2,1)=1.d0
endif
!print *,'Nstart',Nstart
Nstart=MAX(3,Nstart)
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
!print *,'loop starts'
do Ntd=Nstart,Ntime
Ntdc=Ntd+Nc
ex=0.d0
BIG=0.d0
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),Ntd,-1,R0,R1,R2,R3,R4) ! positive wave period
C CALL ECHO(BIG(1:2,1:2))
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
!print *,'test',fxind/CY(1:Nx)
do icy=1,Nx
ansr(Ntd,icy)=fxind(icy)*CC/CY(icy)
enddo
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
if((Nx.gt.4).or.NIT.gt.5) print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 300
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansr(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 continue
deallocate(BIG)
deallocate(ex)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
if (allocated(R3)) then
deallocate(R3)
deallocate(R4)
deallocate(h)
ENDIF
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,def,Ntime,Nstart,NIT,speed,Nx,dT)
IMPLICIT NONE
integer, intent(out):: def,Ntime,Nstart,NIT,speed,Nx
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) def
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
if (abs(def).GT.1) then
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
else
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
endif
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,def,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: def
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
!if (def.LT.0) THEN
! H=-H
!endif
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime,def
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
if (abs(def).GT.1) then
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(4)
close(5)
endif
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,shft,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! For ts>1:
! X(t2)..X(ts),..X(tn-1) X''(ts) X'(t1) X'(tn) X(ts) X(t1) X(tn) X'(ts)
! = [Xt Xd Xc]
!
! For ts<=1:
! X(t2)..,..X(tn-1) X'(t1) X'(tn) Y X(t1) X(tn)
! = [Xt Xd Xc]
!Add Y Condition : Y=h
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
if (ts.LE.1) THEN
Ntd1=tn
N=Ntd1+Nc;
shft=0 ! def=1 want only crest period Tc
else
Ntd1=tn+1
N=Ntd1+4
shft=1 ! def=2 or 3 want Tc Ac or Tcf, Ac
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1+shft) = 0.d0 !cov(X(ti+1),Y)
BIG(i ,Ntd1+2+shft) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+3+shft) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X' (t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X' (tn))
enddo
!call echo(big(1:tn,1:tn),tn)
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
!cov(Xc)
!print *,'t'
BIG(Ntd1+1+shft,Ntd1+1+shft) = 100.d0!100.d0 ! cov(Y,Y)
BIG(Ntd1+1+shft,Ntd1+2+shft) = 0.d0
BIG(Ntd1+1+shft,Ntd1+3+shft) = 0.d0
BIG(Ntd1+2+shft,Ntd1+2+shft) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+2+shft,Ntd1+3+shft) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+3+shft,Ntd1+3+shft) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1+shft) = 0.d0 !cov(X'(tn),Y)
BIG(Ntd1 ,Ntd1+2+shft) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+3+shft) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+1+shft) = 0.d0 !cov(X'(t1),Y)
BIG(Ntd1-1,Ntd1+2+shft) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+3+shft) =-R1(tn) !cov(X'(t1),X(tn))
!call echo(big(1:N,1:N),N)
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
!call echo(big(1:N,1:N),N)
enddo
!if (tn.eq.3) then
!do j=1,N
! do i=j,N
! print *,'test',j,i,BIG(j,i)
! enddo
!call echo(big(1:N,1:N),N)
!enddo
!endif
!call echo(big(1:N,1:N),N)
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2Acdf

@ -1,357 +0,0 @@
PROGRAM cov2mmpdf
C*******************************************************************************
C This program computes joint density of maximum and the following minimum *
C*******************************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,seed1,seed_size
integer :: status,i,j,ij,Nx1
double precision :: ds,dT ! lag spacing for covariances
! f90 cov2mmpdf.f rind51.f
CALL INIT_LEVELS(Ntime,Nstart,NIT,speed,Nx1,dT)
Nx=Nx1*(Nx1-1)/2
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
allocate(h(1:Nx1))
CALL INIT_AMPLITUDES(h,Nx1)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y= X'(t2)...X'(tn-1)||X''(t1) X''(tn)|| X'(t1) X'(tn) X(t1) X(tn) !!
! = [ Xt Xd Xc ] !!
! !!
! Nt=tn-2, Nd=2, Nc=4 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! !!
! There are 3 ( NI=4) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] Y(i)<0. !!
! (indI(2)=Nt) ; for i\in (indI(2)+1,indI(3)], Y(i)<0 (deriv. X''(t1)) !!
! (indI(3)=Nt+1); for i\in (indI(3)+1,indI(4)], Y(i)>0 (deriv. X''(tn)) !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=4; Nd=2
Nc=4; Mb=1
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(R4(1))
XtInf=10.d0*SQRT(-R2(1))
! normalizing constant
CC=TWOPI*SQRT(-R2(1)/R4(1))
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate BIG'
end if
allocate(ex(1:Ntime+Nc),stat=status)
if (status.ne.0) then
print *,'can not allocate ex'
end if
if (Nx.gt.1) then
allocate(ansr(1:Nx1,1:Nx1))
else
allocate(ansr(1,1:Ntime))
end if
ansr=0.d0
allocate(fxind(1:Nx))
fxind=0.d0 !this is not needed
allocate(xc(1:Nc,1:Nx))
allocate(a_up(Mb,NI-1))
allocate(a_lo(Mb,NI-1))
a_up=0.d0
a_lo=0.d0
ij=0
do i=2,Nx1
do j=1,i-1
ij=ij+1
xc(3,ij)=h(i)
xc(4,ij)=h(j)
enddo
enddo
xc(1,1:Nx)=0.d0
xc(2,1:Nx)=0.d0
a_lo(1,1)=-Xtinf
a_lo(1,2)=-XdInf
a_up(1,3)=+XdInf
Nstart=MAX(2,Nstart)
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
do Ntd=Nstart,Ntime
Ntdc=Ntd+Nc
ex=0.d0
BIG=0.d0
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),Ntd,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
ij=0
if (Nx .gt. 1) then
do i=2,Nx1
do j=1,i-1
ij=ij+1
ansr(i,j)=ansr(i,j)+fxind(ij)*CC*dt
enddo
enddo
else
ansr(1,Ntd)=fxind(1)*CC
end if
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 300
300 open (unit=11, file='dens.out', STATUS='unknown')
if (Nx.gt.1) then
do i=1,Nx1
do j=1,Nx1
write(11,*) ansr(i,j)
enddo
enddo
else
do j=1,Ntime
write(11,*) ansr(1,j)
enddo
end if
close(11)
900 continue
deallocate(BIG)
deallocate(ex)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(R0)
deallocate(R1)
deallocate(R2)
deallocate(R3)
deallocate(R4)
deallocate(h)
if (allocated(COV) ) then
deallocate(COV)
endif
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (Ntime,Nstart,NIT,speed,Nx,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,Nstart,NIT,speed,Nx
double precision ,intent(out) :: dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
READ (14,*) dT
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(1)
close(2)
close(3)
close(3)
close(5)
return
END SUBROUTINE INIT_COVARIANCES
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn
integer :: i,j,N
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X'(t1),X'(tn),X(t1),X(tn)
! = [ Xt | Xd | Xc ]
!
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
N=tn+4
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = -R2(j-i+1) ! cov(X'(ti+1),X'(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,tn+3) = R1(i+1) !cov(X'(ti+1),X(t1))
BIG(tn-1-i ,tn+4) = -R1(i+1) !cov(X'(ti+1),X(tn))
BIG(i ,tn+1) = -R2(i+1) !cov(X'(ti+1),X'(t1))
BIG(tn-1-i ,tn+2) = -R2(i+1) !cov(X'(ti+1),X'(tn))
!Cov(Xt,Xd)
BIG(i,tn-1) = R3(i+1) !cov(X'(ti+1),X''(t1))
BIG(tn-1-i,tn) =-R3(i+1) !cov(X'(ti+1),X''(tn))
enddo
!cov(Xd)
BIG(tn-1 ,tn-1 ) = R4(1)
BIG(tn-1,tn ) = R4(tn) !cov(X''(t1),X''(tn))
BIG(tn ,tn ) = R4(1)
!cov(Xc)
BIG(tn+3,tn+3) = R0(1) ! cov(X(t1),X(t1))
BIG(tn+3,tn+4) = R0(tn) ! cov(X(t1),X(tn))
BIG(tn+1,tn+3) = 0.d0 ! cov(X(t1),X'(t1))
BIG(tn+2,tn+3) = R1(tn) ! cov(X(t1),X'(tn))
BIG(tn+4,tn+4) = R0(1) ! cov(X(tn),X(tn))
BIG(tn+1,tn+4) =-R1(tn) ! cov(X(tn),X'(t1))
BIG(tn+2,tn+4) = 0.d0 ! cov(X(tn),X'(tn))
BIG(tn+1,tn+1) =-R2(1) ! cov(X'(t1),X'(t1))
BIG(tn+1,tn+2) =-R2(tn) ! cov(X'(t1),X'(tn))
BIG(tn+2,tn+2) =-R2(1) ! cov(X'(tn),X'(tn))
!Xc=X(t1),X(tn),X'(t1),X'(tn)
!Xd=X''(t1),X''(tn)
!cov(Xd,Xc)
BIG(tn-1 ,tn+3) = R2(1) !cov(X''(t1),X(t1))
BIG(tn-1 ,tn+4) = R2(tn) !cov(X''(t1),X(tn))
BIG(tn-1 ,tn+1) = 0.d0 !cov(X''(t1),X'(t1))
BIG(tn-1 ,tn+2) = R3(tn) !cov(X''(t1),X'(tn))
BIG(tn ,tn+3) = R2(tn) !cov(X''(tn),X(t1))
BIG(tn ,tn+4) = R2(1) !cov(X''(tn),X(tn))
BIG(tn ,tn+1) =-R3(tn) !cov(X''(tn),X'(t1))
BIG(tn ,tn+2) = 0.d0 !cov(X''(tn),X'(tn))
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
RETURN
END SUBROUTINE COV_INPUT
END PROGRAM cov2mmpdf

@ -1,769 +0,0 @@
PROGRAM sp2mmt
C*******************************************************************************
C This program computes joint density of the maximum and the following *
C minimum or level u separated maxima and minima + period/wavelength *
C*******************************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:), allocatable :: BIG
double precision, dimension(:,:,:),allocatable :: ansr
double precision, dimension(: ), allocatable :: ex
double precision, dimension(:,:), allocatable :: xc
double precision, dimension(: ), allocatable :: fxind,h
double precision, dimension(: ), allocatable :: R0,R1,R2,R3,R4
double precision :: CC,U,XdInf,XtInf
double precision, dimension(1,4) :: a_up,a_lo ! size Mb X NI-1
integer , dimension(: ), allocatable :: seed
integer ,dimension(5) :: indI = 0 ! length NI
integer :: Nstart,Ntime,ts,tn,speed,seed1,seed_size
integer :: status,i,j,ij,Nx0,Nx1,DEF,isOdd !,TMP
LOGICAL :: SYMMETRY=.FALSE.
double precision :: dT ! lag spacing for covariances
! f90 -gline -fieee -Nl126 -C -o intmodule.f rind60.f sp2mmt.f
CALL INIT_LEVELS(Ntime,Nstart,NIT,speed,SCIS,SEED1,Nx1,dT,u,def)
CALL INITDATA(speed)
if (SCIS.GT.0) then
!allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
if (ALLOCATED(COV)) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
endif
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
Nx0 = Nx1 ! just plain Mm
IF (def.GT.1) Nx0=2*Nx1 ! level v separated max2min densities wanted
allocate(h(1:Nx0))
CALL INIT_AMPLITUDES(h,Nx0)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
! For DEF = 0,1 : (Maxima, Minima and period/wavelength)
! = 2,3 : (Level v separated Maxima and Minima and period/wavelength between them)
! If Nx==1 then the conditional density for period/wavelength between Maxima and Minima
! given the Max and Min is returned
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Y= X'(t2)..X'(ts)..X'(tn-1)||X''(t1) X''(tn)|| X'(t1) X'(tn) X(t1) X(tn)
! = [ Xt Xd Xc ]
!
! Nt = tn-2, Nd = 2, Nc = 4
!
! Xt= contains Nt time points in the indicator function
! Xd= " Nd derivatives in Jacobian
! Xc= " Nc variables to condition on
!
! There are 3 (NI=4) regions with constant barriers:
! (indI(1)=0); for i\in (indI(1),indI(2)] Y(i)<0.
! (indI(2)=Nt) ; for i\in (indI(2)+1,indI(3)], Y(i)<0 (deriv. X''(t1))
! (indI(3)=Nt+1); for i\in (indI(3)+1,indI(4)], Y(i)>0 (deriv. X''(tn))
!
!
! For DEF = 4,5 (Level v separated Maxima and Minima and period/wavelength from Max to crossing)
! If Nx==1 then the conditional joint density for period/wavelength between Maxima, Minima and Max to
! level v crossing given the Max and the min is returned
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Y= X'(t2)..X'(ts)..X'(tn-1)||X''(t1) X''(tn) X'(ts)|| X'(t1) X'(tn) X(t1) X(tn) X(ts)
! = [ Xt Xd Xc ]
!
! Nt = tn-2, Nd = 3, Nc = 5
!
! Xt= contains Nt time points in the indicator function
! Xd= " Nd derivatives
! Xc= " Nc variables to condition on
!
! There are 4 (NI=5) regions with constant barriers:
! (indI(1)=0); for i\in (indI(1),indI(2)] Y(i)<0.
! (indI(2)=Nt) ; for i\in (indI(2)+1,indI(3)], Y(i)<0 (deriv. X''(t1))
! (indI(3)=Nt+1); for i\in (indI(3)+1,indI(4)], Y(i)>0 (deriv. X''(tn))
! (indI(4)=Nt+2); for i\in (indI(4)+1,indI(5)], Y(i)<0 (deriv. X'(ts))
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!Revised pab 22.04.2000
! - added mean separated min/max + (Tdm, TMd) period distributions
! - added scis
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf = 10.d0*SQRT(R4(1))
XtInf = 10.d0*SQRT(-R2(1))
Nc = 4
NI=4; Nd=2;
Mb=1 ;
Nj = 0
indI(1) = 0
Nstart=MAX(2,Nstart)
isOdd = MOD(Nx1,2)
IF (def.LE.1) THEN ! just plain Mm
Nx = Nx1*(Nx1-1)/2
IJ = (Nx1+isOdd)/2
IF (H(1)+H(Nx1).EQ.0.AND.
& (H(IJ).EQ.0.OR.H(IJ)+H(IJ+1).EQ.0) ) THEN
SYMMETRY=.FALSE.
PRINT *,' Integration region symmetric'
! May save Nx1-isOdd integrations in each time step
! This is not implemented yet.
!Nx = Nx1*(Nx1-1)/2-Nx1+isOdd
ENDIF
CC = TWOPI*SQRT(-R2(1)/R4(1)) ! normalizing constant = 1/ expected number of zero-up-crossings of X'
ELSE ! level u separated Mm
Nx = (Nx1-1)*(Nx1-1)
IF ( ABS(u).LE.1D-8.AND.H(1)+H(Nx1+1).EQ.0.AND.
& (H(Nx1)+H(2*Nx1).EQ.0) ) THEN
SYMMETRY=.FALSE.
PRINT *,' Integration region symmetric'
! Not implemented for DEF <= 3
!IF (DEF.LE.3) Nx = (Nx1-1)*(Nx1-2)/2
ENDIF
IF (DEF.GT.3) THEN
Nstart = MAX(Nstart,3)
Nc = 5
NI=5; Nd=3;
ENDIF
CC = TWOPI*SQRT(-R0(1)/R2(1))*exp(0.5D0*u*u/R0(1)) ! normalizing constant= 1/ expected number of u-up-crossings of X
ENDIF
!print *,'def',def
IF (Nx.GT.1) THEN
IF ((DEF.EQ.0.OR.DEF.EQ.2)) THEN ! (M,m) or (M,m)v distribution wanted
allocate(ansr(Nx1,Nx1,1),stat=status)
ELSE ! (M,m,TMm), (M,m,TMm)v (M,m,TMd)v or (M,M,Tdm)v distributions wanted
allocate(ansr(Nx1,Nx1,Ntime),stat=status)
ENDIF
ELSEIF (DEF.GT.3) THEN ! Conditional distribution for (TMd,TMm)v or (Tdm,TMm)v given (M,m) wanted
allocate(ansr(1,Ntime,Ntime),stat=status)
ELSE ! Conditional distribution for (TMm) or (TMm)v given (M,m) wanted
allocate(ansr(1,1,Ntime),stat=status)
ENDIF
if (status.ne.0) print *,'can not allocate ansr'
allocate(BIG(Ntime+Nc+1,Ntime+Nc+1),stat=status)
if (status.ne.0) print *,'can not allocate BIG'
allocate(ex(1:Ntime+Nc+1),stat=status)
if (status.ne.0) print *,'can not allocate ex'
allocate(fxind(Nx),xc(Nc,Nx))
! Initialization
!~~~~~~~~~~~~~~~~~
BIG = 0.d0
ex = 0.d0
ansr = 0.d0
a_up = 0.d0
a_lo = 0.d0
xc(:,:) = 0.d0
!xc(:,1:Nx) = 0.d0
!xc(2,1:Nx) = 0.d0
a_lo(1,1) = -Xtinf
a_lo(1,2) = -XdInf
a_up(1,3) = +XdInf
a_lo(1,4) = -Xtinf
ij = 0
IF (DEF.LE.1) THEN ! Max2min and period/wavelength
do I=2,Nx1
J = IJ+I-1
xc(3,IJ+1:J) = h(I)
xc(4,IJ+1:J) = h(1:I-1)
IJ = J
enddo
ELSE
! Level u separated Max2min
xc(Nc,:) = u
! H(1) = H(Nx1+1)= u => start do loop at I=2 since by definition we must have: minimum<u-level<Maximum
do i=2,Nx1
J = IJ+Nx1-1
xc(3,IJ+1:J) = h(i) ! Max > u
xc(4,IJ+1:J) = h(Nx1+2:2*Nx1) ! Min < u
IJ = J
enddo
!CALL ECHO(transpose(xc(3:5,:)))
if (DEF.GT.3) GOTO 200
ENDIF
do Ntd = Nstart,Ntime
!Ntd=tn
Ntdc = Ntd+Nc
Nt = Ntd-Nd;
indI(2) = Nt;
indI(3) = Nt+1;
indI(4) = Ntd;
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),Ntd,0,R0,R1,R2,R3,R4) ! positive wave period
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
IF (Nx.LT.2) THEN
! Density of TMm given the Max and the Min. Note that the density is not scaled to unity
ansr(1,1,Ntd) = fxind(1)*CC
GOTO 100
ENDIF
IJ = 0
SELECT CASE (DEF)
CASE(:0)
! joint density of (M,m)
!~~~~~~~~~~~~~~~~~~~~~~~~
do i = 2, Nx1
J = IJ+i-1
ansr(1:i-1,i,1) = ansr(1:i-1,i,1)+fxind(ij+1:J)*CC*dt
IJ=J
enddo
CASE (1)
! joint density of (M,m,TMm)
do i = 2, Nx1
J = IJ+i-1
ansr(1:i-1,i,Ntd) = fxind(ij+1:J)*CC
IJ = J
enddo
CASE (2)
! joint density of level v separated (M,m)v
do i = 2,Nx1
J = IJ+Nx1-1
ansr(2:Nx1,i,1) = ansr(2:Nx1,i,1)+fxind(ij+1:J)*CC*dt
IJ = J
enddo
CASE (3:)
! joint density of level v separated (M,m,TMm)v
do i = 2,Nx1
J = IJ+Nx1-1
ansr(2:Nx1,i,Ntd) = ansr(2:Nx1,i,Ntd)+fxind(ij+1:J)*CC
IJ = J
enddo
END SELECT
100 if (ALLOCATED(COV)) then
write(11,*) COV(:) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 800
200 do tn = Nstart,Ntime
Ntd = tn+1
Ntdc = Ntd + Nc
Nt = Ntd - Nd;
indI(2) = Nt;
indI(3) = Nt + 1;
indI(4) = Nt + 2;
indI(5) = Ntd;
!CALL COV_INPUT2(BIG(1:Ntdc,1:Ntdc),tn,-2,R0,R1,R2,R3,R4) ! positive wave period
IF (SYMMETRY) GOTO 300
do ts = 2,tn-1
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2,R3,R4) ! positive wave period
!print *,'Big='
!CALL ECHO(BIG(1:Ntdc,1:MIN(Ntdc,10)))
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
SELECT CASE (def)
CASE (:4)
IF (Nx.EQ.1) THEN
! Joint density (TMd,TMm) given the Max and the min. Note the density is not scaled to unity
ansr(1,ts,tn) = fxind(1)*CC
ELSE
! 4, gives level u separated Max2min and wave period from Max to the crossing of level u (M,m,TMd).
ij = 0
do i = 2,Nx1
J = IJ+Nx1-1
ansr(2:Nx1,i,ts) = ansr(2:Nx1,i,ts)+
& fxind(ij+1:J)*CC*dt
IJ = J
enddo
ENDIF
CASE (5:)
IF (Nx.EQ.1) THEN
! Joint density (Tdm,TMm) given the Max and the min. Note the density is not scaled to unity
ansr(1,tn-ts+1,tn) = fxind(1)*CC
ELSE
! 5, gives level u separated Max2min and wave period from the crossing of level u to the min (M,m,Tdm).
ij = 0
do i = 2,Nx1
J = IJ+Nx1-1
ansr(2:Nx1,i,tn-ts+1)=ansr(2:Nx1,i,tn-ts+1)+
& fxind(ij+1:J)*CC*dt
IJ = J
enddo
ENDIF
END SELECT
if (ALLOCATED(COV)) then
write(11,*) COV(:) ! save coefficient of variation
endif
enddo
GOTO 400
300 do ts = 2,FLOOR(DBLE(Ntd)/2.d0) ! Using the symmetry since U = 0 and the transformation is linear
CALL COV_INPUT(BIG(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2,R3,R4) ! positive wave period
!print *,'Big='
!CALL ECHO(BIG(1:Ntdc,1:Ntdc))
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex,xc,indI,a_lo,a_up)
IF (Nx.EQ.1) THEN
! Joint density of (TMd,TMm),(Tdm,TMm) given the max and the min. Note that the density is not scaled to unity
ansr(1,ts,tn) = fxind(1)*CC
IF (ts.LT.tn-ts+1) THEN
ansr(1,tn-ts+1,tn) = fxind(1)*CC
ENDIF
GOTO 350
ENDIF
IJ = 0
SELECT CASE (def)
CASE (:4)
! 4, gives level u separated Max2min and wave period from Max to the crossing of level u (M,m,TMd).
do i = 2,Nx1
j = ij+Nx1-1
ansr(2:Nx1,i,ts) = ansr(2:Nx1,i,ts)+
& fxind(ij+1:J)*CC*dt
IF (ts.LT.tn-ts+1) THEN
ansr(i,2:Nx1,tn-ts+1) =
& ansr(i,2:Nx1,tn-ts+1)+fxind(ij+1:J)*CC*dt ! exploiting the symmetry
ENDIF
IJ = J
enddo
CASE (5:)
! 5, gives level u separated Max2min and wave period from the crossing of level u to min (M,m,Tdm).
do i = 2,Nx1
J = IJ+Nx1-1
ansr(2:Nx1,i,tn-ts+1)=ansr(2:Nx1,i,tn-ts+1)+
& fxind(ij+1:J)*CC*dt
IF (ts.LT.tn-ts+1) THEN
ansr(i,2:Nx1,ts) = ansr(i,2:Nx1,ts)+
& fxind(ij+1:J)*CC*dt ! exploiting the symmetry
ENDIF
IJ = J
enddo
END SELECT
350 enddo
400 print *,'Ready: ',tn,' of ',Ntime
enddo
800 open (unit=11, file='dens.out', STATUS='unknown')
!print *,'ans, IJ,def', shape(ansr),IJ,DEF
if (Nx.GT.1) THEN
ij = 1
IF (DEF.GT.2.OR.DEF.EQ.1) IJ = Ntime
!print *,'ans, IJ,def', size(ansr),IJ,DEF
do ts = 1,ij
do j=1,Nx1
do i=1,Nx1
write(11,*) ansr(i,j,ts)
enddo
enddo
enddo
ELSE
ij = 1
IF (DEF.GT.3) IJ = Ntime
!print *,'ans, IJ,def', size(ansr),IJ,DEF
do ts = 1,Ntime
do j = 1,ij
write(11,*) ansr(1,j,ts)
enddo
enddo
ENDIF
close(11)
900 continue
deallocate(BIG)
deallocate(ex)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(R0)
deallocate(R1)
deallocate(R2)
deallocate(R3)
deallocate(R4)
deallocate(h)
if (allocated(COV) ) then
deallocate(COV)
endif
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (Ntime,Nstart,NIT,speed,SCIS,SEED1,Nx,dT,u,def)
IMPLICIT NONE
integer, intent(out):: Ntime,Nstart,NIT,speed,Nx,DEF,SCIS,SEED1
double precision ,intent(out) :: dT,U
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
READ (14,*) dT
READ (14,*) U
READ (14,*) DEF
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(1)
close(2)
close(3)
close(3)
close(5)
return
END SUBROUTINE INIT_COVARIANCES
C**********************************************************************
SUBROUTINE COV_INPUT2(BIG,tn,ts,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,N,shft
! the order of the variables in the covariance matrix
! are organized as follows:
! for ts <= 1:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X'(t1),X'(tn),X(t1),X(tn)
! = [ Xt | Xd | Xc ]
!
! for ts > =2:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X'(t1),X'(tn),X(t1),X(tn) X(ts)
! = [ Xt | Xd | Xc ]
!
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
if (ts.GT.1) THEN
! Assumption: a previous call to covinput has been made
! need only to update the last row and column of big:
N=tn+5
!Cov(Xt,Xc)
do i=1,tn-2
j=abs(i+1-ts)
BIG(i,N) = -sign(R1(j+1),R1(j+1)*dble(ts-i-1)) !cov(X'(ti+1),X(ts))
enddo
!Cov(Xc)
BIG(N ,N) = R0(1) ! cov(X(ts),X(ts))
BIG(tn+3 ,N) = R0(ts) ! cov(X(t1),X(ts))
BIG(tn+4 ,N) = R0(tn-ts+1) ! cov(X(tn),X(ts))
BIG(tn+1 ,N) = -R1(ts) ! cov(X'(t1),X(ts))
BIG(tn+2 ,N) = R1(tn-ts+1) ! cov(X'(tn),X(ts))
!Cov(Xd,Xc)
BIG(tn-1 ,N) = R2(ts) !cov(X''(t1),X(ts))
BIG(tn ,N) = R2(tn-ts+1) !cov(X''(tn),X(ts))
! make lower triangular part equal to upper
do j=1,N-1
BIG(N,j) = BIG(j,N)
enddo
return
endif
IF (ts.LT.0) THEN
shft = 1
N=tn+5;
ELSE
shft = 0
N=tn+4;
ENDIF
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = -R2(j-i+1) ! cov(X'(ti+1),X'(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,tn+3) = R1(i+1) !cov(X'(ti+1),X(t1))
BIG(tn-1-i ,tn+4) = -R1(i+1) !cov(X'(ti+1),X(tn))
BIG(i ,tn+1) = -R2(i+1) !cov(X'(ti+1),X'(t1))
BIG(tn-1-i ,tn+2) = -R2(i+1) !cov(X'(ti+1),X'(tn))
!Cov(Xt,Xd)
BIG(i,tn-1) = R3(i+1) !cov(X'(ti+1),X''(t1))
BIG(tn-1-i,tn) =-R3(i+1) !cov(X'(ti+1),X''(tn))
enddo
!cov(Xd)
BIG(tn-1 ,tn-1 ) = R4(1)
BIG(tn-1 ,tn ) = R4(tn) !cov(X''(t1),X''(tn))
BIG(tn ,tn ) = R4(1)
!cov(Xc)
BIG(tn+3 ,tn+3) = R0(1) ! cov(X(t1),X(t1))
BIG(tn+3 ,tn+4) = R0(tn) ! cov(X(t1),X(tn))
BIG(tn+1 ,tn+3) = 0.d0 ! cov(X(t1),X'(t1))
BIG(tn+2 ,tn+3) = R1(tn) ! cov(X(t1),X'(tn))
BIG(tn+4 ,tn+4) = R0(1) ! cov(X(tn),X(tn))
BIG(tn+1 ,tn+4) =-R1(tn) ! cov(X(tn),X'(t1))
BIG(tn+2 ,tn+4) = 0.d0 ! cov(X(tn),X'(tn))
BIG(tn+1 ,tn+1) =-R2(1) ! cov(X'(t1),X'(t1))
BIG(tn+1 ,tn+2) =-R2(tn) ! cov(X'(t1),X'(tn))
BIG(tn+2 ,tn+2) =-R2(1) ! cov(X'(tn),X'(tn))
!Xc=X(t1),X(tn),X'(t1),X'(tn)
!Xd=X''(t1),X''(tn)
!cov(Xd,Xc)
BIG(tn-1 ,tn+3) = R2(1) !cov(X''(t1),X(t1))
BIG(tn-1 ,tn+4) = R2(tn) !cov(X''(t1),X(tn))
BIG(tn-1 ,tn+1) = 0.d0 !cov(X''(t1),X'(t1))
BIG(tn-1 ,tn+2) = R3(tn) !cov(X''(t1),X'(tn))
BIG(tn ,tn+3) = R2(tn) !cov(X''(tn),X(t1))
BIG(tn ,tn+4) = R2(1) !cov(X''(tn),X(tn))
BIG(tn ,tn+1) =-R3(tn) !cov(X''(tn),X'(t1))
BIG(tn ,tn+2) = 0.d0 !cov(X''(tn),X'(tn))
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
BIG(i,j) = BIG(j,i)
enddo
enddo
RETURN
END SUBROUTINE COV_INPUT2
SUBROUTINE COV_INPUT(BIG,tn,ts,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,N,shft, tnold = 0
! the order of the variables in the covariance matrix
! are organized as follows:
! for ts <= 1:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X'(t1),X'(tn),X(t1),X(tn)
! = [ Xt | Xd | Xc ]
!
! for ts > =2:
! X'(t2)..X'(ts),...,X'(tn-1) X''(t1),X''(tn) X'(ts) X'(t1),X'(tn),X(t1),X(tn) X(ts)
! = [ Xt | Xd | Xc ]
!
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s)) = r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
SAVE tnold
if (ts.GT.1) THEN
shft = 1
N=tn+5+shft
!Cov(Xt,Xc)
do i=1,tn-2
j=abs(i+1-ts)
BIG(i,N) = -sign(R1(j+1),R1(j+1)*dble(ts-i-1)) !cov(X'(ti+1),X(ts))
enddo
!Cov(Xc)
BIG(N ,N) = R0(1) ! cov(X(ts),X(ts))
BIG(tn+shft+3 ,N) = R0(ts) ! cov(X(t1),X(ts))
BIG(tn+shft+4 ,N) = R0(tn-ts+1) ! cov(X(tn),X(ts))
BIG(tn+shft+1 ,N) = -R1(ts) ! cov(X'(t1),X(ts))
BIG(tn+shft+2 ,N) = R1(tn-ts+1) ! cov(X'(tn),X(ts))
!Cov(Xd,Xc)
BIG(tn-1 ,N) = R2(ts) !cov(X''(t1),X(ts))
BIG(tn ,N) = R2(tn-ts+1) !cov(X''(tn),X(ts))
!ADD a level u crossing at ts
!Cov(Xt,Xd)
do i = 1,tn-2
j = abs(i+1-ts)
BIG(i,tn+shft) = -R2(j+1) !cov(X'(ti+1),X'(ts))
enddo
!Cov(Xd)
BIG(tn+shft,tn+shft) = -R2(1) !cov(X'(ts),X'(ts))
BIG(tn-1 ,tn+shft) = R3(ts) !cov(X''(t1),X'(ts))
BIG(tn ,tn+shft) = -R3(tn-ts+1) !cov(X''(tn),X'(ts))
!Cov(Xd,Xc)
BIG(tn+shft ,N ) = 0.d0 !cov(X'(ts),X(ts))
BIG(tn+shft,tn+shft+3) = R1(ts) ! cov(X'(ts),X(t1))
BIG(tn+shft,tn+shft+4) = -R1(tn-ts+1) ! cov(X'(ts),X(tn))
BIG(tn+shft,tn+shft+1) = -R2(ts) ! cov(X'(ts),X'(t1))
BIG(tn+shft,tn+shft+2) = -R2(tn-ts+1) ! cov(X'(ts),X'(tn))
IF (tnold.EQ.tn) THEN ! A previous call to covinput with tn==tnold has been made
! need only to update row and column N and tn+1 of big:
! make lower triangular part equal to upper and then return
do j=1,tn+shft
BIG(N,j) = BIG(j,N)
BIG(tn+shft,j) = BIG(j,tn+shft)
enddo
do j=tn+shft+1,N-1
BIG(N,j) = BIG(j,N)
BIG(j,tn+shft) = BIG(tn+shft,j)
enddo
return
ENDIF
tnold = tn
ELSE
N = tn+4
shft = 0
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = -R2(j-i+1) ! cov(X'(ti+1),X'(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,tn+shft+3) = R1(i+1) !cov(X'(ti+1),X(t1))
BIG(tn-1-i ,tn+shft+4) = -R1(i+1) !cov(X'(ti+1),X(tn))
BIG(i ,tn+shft+1) = -R2(i+1) !cov(X'(ti+1),X'(t1))
BIG(tn-1-i ,tn+shft+2) = -R2(i+1) !cov(X'(ti+1),X'(tn))
!Cov(Xt,Xd)
BIG(i,tn-1) = R3(i+1) !cov(X'(ti+1),X''(t1))
BIG(tn-1-i,tn) =-R3(i+1) !cov(X'(ti+1),X''(tn))
enddo
!cov(Xd)
BIG(tn-1 ,tn-1 ) = R4(1)
BIG(tn-1 ,tn ) = R4(tn) !cov(X''(t1),X''(tn))
BIG(tn ,tn ) = R4(1)
!cov(Xc)
BIG(tn+shft+3 ,tn+shft+3) = R0(1) ! cov(X(t1),X(t1))
BIG(tn+shft+3 ,tn+shft+4) = R0(tn) ! cov(X(t1),X(tn))
BIG(tn+shft+1 ,tn+shft+3) = 0.d0 ! cov(X(t1),X'(t1))
BIG(tn+shft+2 ,tn+shft+3) = R1(tn) ! cov(X(t1),X'(tn))
BIG(tn+shft+4 ,tn+shft+4) = R0(1) ! cov(X(tn),X(tn))
BIG(tn+shft+1 ,tn+shft+4) =-R1(tn) ! cov(X(tn),X'(t1))
BIG(tn+shft+2 ,tn+shft+4) = 0.d0 ! cov(X(tn),X'(tn))
BIG(tn+shft+1 ,tn+shft+1) =-R2(1) ! cov(X'(t1),X'(t1))
BIG(tn+shft+1 ,tn+shft+2) =-R2(tn) ! cov(X'(t1),X'(tn))
BIG(tn+shft+2 ,tn+shft+2) =-R2(1) ! cov(X'(tn),X'(tn))
!Xc=X(t1),X(tn),X'(t1),X'(tn)
!Xd=X''(t1),X''(tn)
!cov(Xd,Xc)
BIG(tn-1 ,tn+shft+3) = R2(1) !cov(X''(t1),X(t1))
BIG(tn-1 ,tn+shft+4) = R2(tn) !cov(X''(t1),X(tn))
BIG(tn-1 ,tn+shft+1) = 0.d0 !cov(X''(t1),X'(t1))
BIG(tn-1 ,tn+shft+2) = R3(tn) !cov(X''(t1),X'(tn))
BIG(tn ,tn+shft+3) = R2(tn) !cov(X''(tn),X(t1))
BIG(tn ,tn+shft+4) = R2(1) !cov(X''(tn),X(tn))
BIG(tn ,tn+shft+1) =-R3(tn) !cov(X''(tn),X'(t1))
BIG(tn ,tn+shft+2) = 0.d0 !cov(X''(tn),X'(tn))
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
BIG(i,j) = BIG(j,i)
enddo
enddo
RETURN
END SUBROUTINE COV_INPUT
END PROGRAM sp2mmt

@ -1,498 +0,0 @@
PROGRAM sp2tccpdf
C***********************************************************************
C This program computes: *
C *
C density of T= T_1+T_2 in a gaussian process i.e. *
C *
C wavelengthes for crests <h1 and troughs >h2 *
C *
C Sylvie and Igor 7 dec. 1999 *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
& NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex,CY1,CY2
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h1,h2
double precision, dimension(: ),allocatable :: hh1,hh2
double precision, dimension(: ),allocatable :: R0,R1,R2
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Ntime,tn,ts,speed,ph,seed1,seed_size,Nx1,Nx2,N0
integer :: icy,icy2
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -g2 -C -automatic -o ~/WAT/V4/sp2tthpdf1.exe rind49.f sp2tthpdf1.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../sp2tthpdf.exe rind49.f sp2tthpdf1.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
!print *,'U,Ntime,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,Ntime,NIT,speed,SCIS,seed1,Nx,dT
!Nx1=1
!Nx2=1
Nx=Nx1*Nx1
!print *,'NN',Nx1,Nx2,Nx
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(h1(1:Nx1))
allocate(h2(1:Nx2))
CALL INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2)
allocate(hh1(1:Nx))
allocate(hh2(1:Nx))
!h transformation
do icy=1,Nx1
do icy2=1,Nx2
hh1((icy-1)*Nx2+icy2)=h1(icy);
hh2((icy-1)*Nx2+icy2)=h2(icy2);
enddo
enddo
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!h1(1)=XtInf
!h2(1)=XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY1(1:Nx))
allocate(CY2(1:Nx))
do icy=1,Nx
CY1(icy)=exp(-0.5*hh1(icy)*hh1(icy)/100)/(10*sqrt(twopi))
CY2(icy)=exp(-0.5*hh2(icy)*hh2(icy)/100)/(10*sqrt(twopi))
enddo
!print *,CY1
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
fxind=0.d0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y={X(t2)..,X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)} !!
! = [Xt Xd Xc] !!
! !!
! Nt=tn-2, Nd=3, Nc=2+3 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! (Y1,Y2) dummy variables ind. of all other v. inputing h1,h2 into rindd !!
! !!
! There are 6 ( NI=7) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] u<Y(i)<h1 !!
! (indI(2)=ts-2); for i\in (indI(2),indI(2)], inf<Y(i)<inf (no restr.) !!
! (indI(3)=ts-1); for i\in (indI(3),indI(4)], h2 <Y(i)<u !!
! (indI(4)=Nt) ; for i\in (indI(4),indI(5)], Y(i)<0 (deriv. X'(ts)) !!
! (indI(5)=Nt+1); for i\in (indI(5),indI(6)], Y(i)>0 (deriv. X'(t1)) !!
! (indI(6)=Nt+2); for i\in (indI(6),indI(7)], Y(i)>0 (deriv. X'(tn)) !!
! (indI(7)=Nt+3); NI=7. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=7; Nd=3
Nc=5; Mb=3
allocate(a_up(1:Mb,1:(NI-1)))
allocate(a_lo(1:Mb,1:(NI-1)))
a_up=0.d0
a_lo=0.d0
allocate(BIG(1:(Ntime+Nc+1),1:(Ntime+Nc+1)))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:(Ntime+Nc+1)))
!print *,size(ex),Ntime
ex=0.d0
!print *,size(ex),ex
xc(1,1:Nx)=hh1(1:Nx)
xc(2,1:Nx)=hh2(1:Nx)
xc(3,1:Nx)=u
xc(4,1:Nx)=u
xc(5,1:Nx)=u
! upp- down- upp-crossings at t1,ts,tn
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(1,3)=u
a_lo(1,4)=-XdInf
a_up(1,5)= XdInf
a_up(1,6)= XdInf
a_up(2,1)=1.d0
a_lo(3,3)=1.d0 !signe a voir!!!!!!
! print *,a_up
! print *,a_lo
do tn=N0,Ntime,1
! do tn=Ntime,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
if (SCIS.gt.0) then
if (SCIS.EQ.2) then
Nj=max(Nt,0)
else
Nj=min(max(Nt-5, 0),0)
endif
endif
do ts=3,tn-2
!print *,'ts,tn' ,ts,tn,Ntdc
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2)!positive wave period
indI(2)=ts-2
indI(3)=ts-1
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
ds=dt
do icy=1,Nx
! ansr(tn,:)=ansr(tn,:)+fxind*CC*ds./(CY1.*CY2)
ansr(tn,icy)=ansr(tn,icy)+fxind(icy)*CC*ds/(CY1(icy)*CY2(icy))
enddo
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime
enddo !tn
!print *,'ansr',ansr
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
!write(11,*) ansr(ts,ph),hh1(ph),hh2(ph)
write(11,111) ansr(ts,ph)
enddo
enddo
111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
deallocate(h1)
deallocate(h2)
deallocate(hh1)
deallocate(hh2)
deallocate(a_up)
deallocate(a_lo)
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,N0,NIT,speed,Nx1,Nx2,SCIS,seed1
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) Ntime
READ (14,*) N0
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx1,Nx2
READ (14,*) dT
if (Ntime.lt.5) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h1,h2
integer, intent(in) :: Nx1,Nx2
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx1
READ (4,*) H1(ix)
enddo
do ix=1,Nx2
READ (4,*) H2(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
integer ,intent(in) :: tn,ts
integer :: i,j,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
!
! ||X(t2)..X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
Ntd1=tn+1
N=Ntd1+Nc
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1) = 0.d0 !cov(X(ti+1),Y1)
BIG(i ,Ntd1+2) = 0.d0 !cov(X(ti+1),Y2)
BIG(i ,Ntd1+4) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+5) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X'(t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X'(tn))
enddo
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
BIG(Ntd1-2,Ntd1-1) = -R2(ts) !cov(X'(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = -R2(1)
BIG(Ntd1-2,Ntd1 ) = -R2(tn+1-ts) !cov(X'(ts),X'(tn))
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = 100.d0 ! cov(Y1 Y1)
BIG(Ntd1+1,Ntd1+2) = 0.d0 ! cov(Y1 Y2)
BIG(Ntd1+1,Ntd1+3) = 0.d0 ! cov(Y1 X(ts))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(Y1 X(t1))
BIG(Ntd1+1,Ntd1+5) = 0.d0 ! cov(Y1 X(tn))
BIG(Ntd1+2,Ntd1+2) = 100.d0 ! cov(Y2 Y2)
BIG(Ntd1+2,Ntd1+3) = 0.d0 ! cov(Y2 X(ts))
BIG(Ntd1+2,Ntd1+4) = 0.d0 ! cov(Y2 X(t1))
BIG(Ntd1+2,Ntd1+5) = 0.d0 ! cov(Y2 X(tn))
BIG(Ntd1+3,Ntd1+3) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+3,Ntd1+4) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+3,Ntd1+5) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+4,Ntd1+4) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+4,Ntd1+5) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+5,Ntd1+5) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1) = 0.d0 !cov(X'(tn),Y1)
BIG(Ntd1 ,Ntd1+2) = 0.d0 !cov(X'(tn),Y2)
BIG(Ntd1-1 ,Ntd1+1) = 0.d0 !cov(X'(t1),Y1)
BIG(Ntd1-1 ,Ntd1+2) = 0.d0 !cov(X'(t1),Y2)
BIG(Ntd1-2 ,Ntd1+1) = 0.d0 !cov(X'(ts),Y1)
BIG(Ntd1-2 ,Ntd1+2) = 0.d0 !cov(X'(ts),Y2)
BIG(Ntd1 ,Ntd1+4) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+5) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+4) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+5) =-R1(tn) !cov(X'(t1),X(tn))
BIG(Ntd1 ,Ntd1+3) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+3) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+3) = 0.d0 !cov(X'(ts),X (ts)
BIG(Ntd1-2,Ntd1+4) = R1(ts) !cov(X'(ts),X (t1))
BIG(Ntd1-2,Ntd1+5) = -R1(tn+1-ts) !cov(X'(ts),X (tn))
do i=1,tn-2
j=abs(i+1-ts)
!cov(Xt,Xc)
BIG(i,Ntd1+3) = R0(j+1) !cov(X(ti+1),X(ts))
!Cov(Xt,Xd)
if ((i+1-ts).lt.0) then
BIG(i,Ntd1-2) = R1(j+1)
else !cov(X(ti+1),X'(ts))
BIG(i,Ntd1-2) = -R1(j+1)
endif
enddo
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2tccpdf

@ -1,440 +0,0 @@
PROGRAM sp2tcpdf
C***********************************************************************
C This program computes: *
C *
C density of T_i, for Ac <=h, in a gaussian process i.e. *
C *
C half wavelength (up-crossing to downcrossing) for crests <h *
C or half wavelength (down-crossing to upcrossing) for trough >h *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
&NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex,CY
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(2,6) :: a_up=0.d0,a_lo=0.d0
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,ph,def,seed1,seed_size,icy
integer ::it1,it2
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -o ~/WAT/V1/sp2tcpdf.exe rind44.f sp2tcpdf.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,def,Ntime,Nstart,NIT,speed,Nx,dT)
!print *,'U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
if (abs(def).GT.1) THEN
!allocate(h(1:Nx))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
!CALL INIT_AMPLITUDES(h,def,Nx)
endif
allocate(h(1:Nx))
CALL INIT_AMPLITUDES(h,def,Nx)
CALL INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
print *,'Nx',Nx
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
print *,'XdInf,XtInf'
print *,XdInf,XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
!fy(h)
allocate(CY(1:Nx))
do icy=1,Nx
CY(icy)=exp(-0.5*h(icy)*h(icy)/100)/(10*sqrt(twopi))
enddo
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
fxind=0.d0 !this is not needed
NI=4; Nd=2
Nc=3; Mb=2
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc))
allocate(xc(1:Nc,1:Nx))
allocate(ex(1:Ntime+Nc))
ex=0.d0
!print *,'nc',Nc,Nx
xc(1,1:Nx)=h(1:Nx)
print *,'xc',h(1)
print *,'test',def;
xc(2,1:Nx)=u
xc(3,1:Nx)=u
if (def.GT.0) then
a_up(1,1)=u !+XtInf
a_lo(1,1)=u
a_up(1,2)=XdInf
a_lo(1,3)=-XdInf
a_up(2,1)=1.d0
else
a_up(1,1)=u
a_lo(1,1)=u !-XtInf
a_lo(1,2)=-XdInf
a_up(1,3)= XdInf
a_lo(2,1)=1.d0
print *,'a_lo',a_lo(2,1)
endif
!print *,'Nstart',Nstart
Nstart=MAX(3,Nstart)
!print *,'Nstart',Nstart
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
do Ntd=Nstart,Ntime
!CALL COV_INPUT2(BIG,Ntd, R0,R1,R2)
Ntdc=Ntd+Nc;
CALL COV_INPUT(BIG,Ntd,-1,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
!Ntdc=Ntd+Nc;
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
! print *,'test',fxind/CY(1:Nx)
do icy=1,Nx
ansr(Ntd,icy)=fxind(icy)*CC/CY(icy)
enddo
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
goto 300
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansr(ts,ph)
! write(11,111) ansr(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
if (allocated(R3)) then
deallocate(R3)
deallocate(R4)
deallocate(h)
ENDIF
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,def,Ntime,Nstart,NIT,speed,Nx,dT)
IMPLICIT NONE
integer, intent(out):: def,Ntime,Nstart,NIT,speed,Nx
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) def
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
print *,'def',def
if (abs(def).GT.1) then
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
else
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
endif
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,def,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: def
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
!if (def.LT.0) THEN
! H=-H
!endif
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime,def
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
if (abs(def).GT.1) then
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(4)
close(5)
endif
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,shft,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! For ts>1:
! X(t2)..X(ts),..X(tn-1) X''(ts) X'(t1) X'(tn) X(ts) X(t1) X(tn) X'(ts)
! = [Xt Xd Xc]
!
! For ts<=1:
! X(t2)..,..X(tn-1) X'(t1) X'(tn) Y X(t1) X(tn)
! = [Xt Xd Xc]
!Add Y Condition : Y=h
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
if (ts.LE.1) THEN
Ntd1=tn
N=Ntd1+Nc;
shft=0 ! def=1 want only crest period Tc
else
Ntd1=tn+1
N=Ntd1+4
shft=1 ! def=2 or 3 want Tc Ac or Tcf, Ac
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1+shft) = 0.d0 !cov(X(ti+1),Y)
BIG(i ,Ntd1+2+shft) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+3+shft) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X' (t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X' (tn))
enddo
!call echo(big(1:tn,1:tn),tn)
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
!cov(Xc)
!print *,'t'
BIG(Ntd1+1+shft,Ntd1+1+shft) = 100.d0!100.d0 ! cov(Y,Y)
BIG(Ntd1+1+shft,Ntd1+2+shft) = 0.d0
BIG(Ntd1+1+shft,Ntd1+3+shft) = 0.d0
BIG(Ntd1+2+shft,Ntd1+2+shft) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+2+shft,Ntd1+3+shft) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+3+shft,Ntd1+3+shft) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1+shft) = 0.d0 !cov(X'(tn),Y)
BIG(Ntd1 ,Ntd1+2+shft) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+3+shft) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+1+shft) = 0.d0 !cov(X'(t1),Y)
BIG(Ntd1-1,Ntd1+2+shft) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+3+shft) =-R1(tn) !cov(X'(t1),X(tn))
!call echo(big(1:N,1:N),N)
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
!call echo(big(1:N,1:N),N)
enddo
!if (tn.eq.3) then
!do j=1,N
! do i=j,N
! print *,'test',j,i,BIG(j,i)
! enddo
!call echo(big(1:N,1:N),N)
!enddo
!endif
!call echo(big(1:N,1:N),N)
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2tcpdf

@ -1,569 +0,0 @@
PROGRAM sp2thpdf
!***********************************************************************
! This program computes: *
! *
! density of S_i,Hi,T_i in a gaussian process i.e. *
! *
! quart wavelength (up-crossing to crest) and crest amplitude *
!
! def = 1, gives half wave period, Tc (default).
! -1, gives half wave period, Tt.
! 2, gives half wave period and wave crest amplitude (Tc,Ac).
! -2, gives half wave period and wave trough amplitude (Tt,At).
! 3, gives crest front period and wave crest amplitude (Tcf,Ac).
! -3, gives trough back period and wave trough amplitude (Ttb,At).
! 4, gives minimum of crest front/back period and wave crest
! amplitude (max(Tcf,Tcb),Ac).
! -4, gives minimum of trough front/back period and wave trough
! amplitude (max(Ttf,Ttb),At).
!***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
& NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(2,6) :: a_up=0.d0,a_lo=0.d0
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nstart,Ntime,tn,ts,speed,ph,def,seed1,seed_size
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -g2 -C -automatic -o ../wave/alpha/sp2thpdf.exe rind44.f sp2thpdf.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../wave/sol2/sp2thpdf.exe rind44.f sp2thpdf.f
! linux:
! f90 -gline -Nl126 -C -o sp2thpdf.exe rind45.f sp2thpdf.f
! HP700
!f90 -g -C -o ../exec/hp700/sp2thpdf.exe rind45.f sp2thpdf.f
!f90 -g -C +check=all +FPVZID -o ../exec/hp700/sp2thpdf2.exe rind45.f sp2thpdf.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT)
!print *,'U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
if (abs(def).GT.1) THEN
allocate(h(1:Nx))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
CALL INIT_AMPLITUDES(h,def,Nx)
endif
CALL INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
!print *,'Nx',Nx
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!print *,'XdInf,XtInf'
!print *,XdInf,XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
if (abs(def).EQ.4) CC=2.d0*CC
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
!fxind=0.d0 this is not needed
if (abs(def).GT.1) then
GOTO 200
endif
NI=4; Nd=2
Nc=2; Mb=1
Nx=1
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc))
allocate(xc(1:Nc,1:Nx))
allocate(ex(1:Ntime+Nc))
ex=0.d0
xc(1,1)=u
xc(2,1)=u
if (def.GT.0) then
a_up(1,1)=u+XtInf
a_lo(1,1)=u
a_up(1,2)=XdInf
a_lo(1,3)=-XdInf
else
a_up(1,1)=u
a_lo(1,1)=u-XtInf
a_lo(1,2)=-XdInf
a_up(1,3)= XdInf
endif
!print *,'Nstart',Nstart
Nstart=MAX(2,Nstart)
!print *,'Nstart',Nstart
if (SCIS.GT.0) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
do Ntd=Nstart,Ntime
!CALL COV_INPUT2(BIG,Ntd, R0,R1,R2)
CALL COV_INPUT(BIG,Ntd,-1,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
Ntdc=Ntd+Nc;
!if (SCIS.gt.0) then
! if (SCIS.EQ.2) then
! Nj=max(Nt,0)
! else
! Nj=min(max(Nt-5, 0),0)
! endif
!endif
!Ex=0.d0
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
ansr(Ntd,1)=fxind(1)*CC
if (SCIS.GT.0) then
write(11,*) COV(1) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
if (SCIS.GT.0) then
close(11)
endif
goto 300
200 continue
XddInf=10.d0*SQRT(R4(1))
NI=7; Nd=3
Nc=4; Mb=2
allocate(BIG(1:Ntime+Nc+1,1:Ntime+Nc+1))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:Ntime+Nc+1))
ex=0.d0
xc(1,1:Nx)=h
xc(2,1:Nx)=u
xc(3,1:Nx)=u
xc(4,1:Nx)=0.d0
if (def.GT.0) then
a_up(2,1)=1.d0 !*h
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(2,2)=1.d0 ! *h
a_lo(2,2)=1.d0 ! *h
a_up(2,3)=1.d0 !*h
a_lo(1,3)=u
a_lo(1,4)=-XddInf
a_up(1,5)= XdInf
a_lo(1,6)=-XdInf
else !def<0
a_up(1,1)=u
a_lo(2,1)=1.d0 !*h
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(2,2)=1.d0 ! *h
a_lo(2,2)=1.d0 ! *h
a_up(1,3)=u
a_lo(2,3)=1.d0 !*h
a_up(1,4)=XddInf
a_lo(1,5)=-XdInf
a_up(1,6)=XdInf
endif
Nstart=MAX(Nstart,3)
do tn=Nstart,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
if (SCIS.gt.0) then
if (SCIS.EQ.2) then
Nj=max(Nt,0)
else
Nj=min(max(Nt-5, 0),0)
endif
endif
do ts=2,FLOOR(DBLE(tn+1)/2.d0)
!print *,'ts,tn' ,ts,tn
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2,R3,R4) ! positive wave period
indI(2)=ts-2
indI(3)=ts-1
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
!print *,'sp call rind'
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
!print *,'sp rind finished',fxind
!goto 900
if (abs(def).LT.3) THEN
if (ts .EQ.tn-ts+1) then
ds=dt
else
ds=2.d0*dt
endif
ansr(tn,1:Nx)=ansr(tn,1:Nx)+fxind*CC*ds
else
ansr(ts,1:Nx)=ansr(ts,1:Nx)+fxind*CC*dT
if ((ts.LT.tn-ts+1).and. (abs(def).lt.4)) THEN
ansr(tn-ts+1,1:Nx)=ansr(tn-ts+1,1:Nx)+fxind*CC*dT ! exploiting the symmetry
endif
endif
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime
enddo !tn
!print *,'ansr',ansr
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansr(ts,ph)
! write(11,111) ansr(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
if (allocated(R3)) then
deallocate(R3)
deallocate(R4)
deallocate(h)
ENDIF
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT)
IMPLICIT NONE
integer, intent(out):: def,Ntime,Nstart,NIT,speed,Nx,SCIS,seed1
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) def
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
if (abs(def).GT.1) then
READ (14,*) Nx
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
else
Nx=1
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
endif
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,def,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: def
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
!if (def.LT.0) THEN
! H=-H
!endif
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime,def
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
if (abs(def).GT.1) then
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(4)
close(5)
endif
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,shft,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
! For ts>1:
! ||X(t2)..X(ts),..X(tn-1)||X''(ts) X'(t1) X'(tn)||X(ts) X(t1) X(tn) X'(ts)||
! = [Xt Xd Xc]
!
! For ts<=1:
! ||X(t2)..,..X(tn-1)||X'(t1) X'(tn)||X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
if (ts.LE.1) THEN
Ntd1=tn
N=Ntd1+2;
shft=0 ! def=1 want only crest period Tc
else
Ntd1=tn+1
N=Ntd1+4
shft=1 ! def=2 or 3 want Tc Ac or Tcf, Ac
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1+shft) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+2+shft) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X' (t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X' (tn))
enddo
!call echo(big(1:tn,1:tn),tn)
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
!cov(Xc)
BIG(Ntd1+1+shft,Ntd1+1+shft) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+1+shft,Ntd1+2+shft) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+2+shft,Ntd1+2+shft) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1+shft) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+2+shft) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+1+shft) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+2+shft) =-R1(tn) !cov(X'(t1),X(tn))
if (ts.GT.1) then
!
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+1,Ntd1+2) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+1,Ntd1+3) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(X(ts),X'(ts))
BIG(Ntd1+2,Ntd1+4) = R1(ts) ! cov(X(t1),X'(ts))
BIG(Ntd1+3,Ntd1+4) = -R1(tn+1-ts) !cov(X(tn),X'(ts))
BIG(Ntd1+4,Ntd1+4) = -R2(1) ! cov(X'(ts),X'(ts))
!cov(Xd)
BIG(Ntd1-2,Ntd1-1) = -R3(ts) !cov(X''(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = R4(1)
BIG(Ntd1-2,Ntd1 ) = R3(tn+1-ts) !cov(X''(ts),X'(tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+4) =-R2(tn+1-ts) !cov(X'(tn),X'(ts))
BIG(Ntd1 ,Ntd1+1) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+4) =-R2(ts) !cov(X'(t1),X'(ts))
BIG(Ntd1-1,Ntd1+1) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+1) = R2(1) !cov(X''(ts),X (ts)
BIG(Ntd1-2,Ntd1+2) = R2(ts) !cov(X''(ts),X (t1))
BIG(Ntd1-2,Ntd1+3) = R2(tn+1-ts) !cov(X''(ts),X (tn))
BIG(Ntd1-2,Ntd1+4) = 0.d0 !cov(X''(ts),X'(ts))
!cov(Xt,Xc)
do i=1,tn-2
j=abs(i+1-ts)
BIG(i,Ntd1+1) = R0(j+1) !cov(X(ti+1),X(ts))
BIG(i,Ntd1+4) = sign(R1(j+1),R1(j+1)*dble(ts-i-1)) !cov(X(ti+1),X'(ts)) ! check this
!Cov(Xt,Xd)=cov(X(ti+1),X(ts))
BIG(i,Ntd1-2) = R2(j+1) !cov(X(ti+1),X''(ts))
enddo
endif ! ts>1
!call echo(big(1:N,1:N),N)
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
!call echo(big(1:N,1:N),N)
enddo
!call echo(big(1:N,1:N),N)
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2thpdf

@ -1,632 +0,0 @@
PROGRAM sp2thpdf
!***********************************************************************
! This program computes: *
! *
! density of S_i,Hi,T_i in a gaussian process i.e. *
! *
! quart wavelength (up-crossing to crest) and crest amplitude *
!
! def = 1, gives half wave period, Tc (default).
! -1, gives half wave period, Tt.
! 2, gives half wave period and wave crest amplitude (Tc,Ac).
! -2, gives half wave period and wave trough amplitude (Tt,At).
! 3, gives crest front period and wave crest amplitude (Tcf,Ac).
! -3, gives trough back period and wave trough amplitude (Ttb,At).
! 4, gives minimum of crest front/back period and wave crest
! amplitude (min(Tcf,Tcb),Ac).
! -4, gives minimum of trough front/back period and wave trough
! amplitude (min(Ttf,Ttb),At).
!***********************************************************************
!History:
! revised Per A. Brodtkorb 04.04.2000
! -
! revised Per A. Brodtkorb 23.11.99
! - fixed a bug in calculating pdf for def = +/- 4
! revised Per A. Brodtkorb 03.11.99
! - added def = +/-4
! revised Per A. Brodtkorb 23.09.99
! - minor changes to covinput
! - removed the calculation of the transformation to spec2thpdf.m
! by Igor Rychlik
use GLOBALDATA, only : rateLHD,SCIS,NSIMmax,COV,ABSEPS
use globalconst
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansr
double precision, dimension(: ),allocatable :: ex
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(: ),allocatable :: fxind,h
double precision, dimension(: ),allocatable :: R0,R1,R2,R3,R4
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(2,6) :: a_up=0.d0,a_lo=0.d0
integer, dimension(6) :: INFIN=2
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Nx,Nt,Nc,Nd,NI,Mb,Ntd, Ntdc
integer :: Nstart,Ntime,tn,ts,speed,ph,def,seed1,seed_size
double precision :: dT, EPSOLD ! lag spacing for covariances
LOGICAL :: init=.TRUE.
! DIGITAL:
! f90 -g2 -C -automatic -o ../wave/alpha/sp2thpdf.exe rind44.f sp2thpdf.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../wave/sol2/sp2thpdf.exe rind44.f sp2thpdf.f
! linux:
! f90 -gline -Nl126 -C -o ../exec/lnx86/sp2thpdf8.exe intmodule.f rind60.f sp2thpdf.f
! f90 -gline -Nl126 -C -o sp2thpdf.exe rind45.f sp2thpdf.f
! f90 -gline -Nl126 -C -o ../exec/lnx86/sp2thpdf3.exe adaptmodule.f krbvrcmod.f krobovmod.f rcrudemod.f rind55.f sp2thpdf.f
! HP700
!f90 -g -C -o ../exec/hp700/sp2thpdf.exe rind45.f sp2thpdf.f
!f90 -g -C +check=all +FPVZID -o ../exec/hp700/sp2thpdf.exe rind45.f sp2thpdf.f
! f90 +gprof +extend_source +Oall +Odataprefetch +Ofastaccess +Oinfo +Oprocelim -C +check=all -o ../exec/hp700/sp2thpdf.exe rind48.f sp2thpdf.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,def,Ntime,Nstart,speed,SCIS,seed1,
& Nx,dT,rateLHD)
!print *,'U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,def,Ntime,Nstart,NIT,speed,SCIS,seed1,Nx,dT
if (SCIS.GT.0) then
!allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
if (abs(def).GT.1) THEN
allocate(h(1:Nx))
allocate(R3(1:Ntime+1))
allocate(R4(1:Ntime+1))
CALL INIT_AMPLITUDES(h,def,Nx)
endif
CALL INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
!print *,'Nx',Nx
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!print *,'XdInf,XtInf'
!print *,XdInf,XtInf
! normalizing constant
CC=TWPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(ansr(1:Ntime,1:Nx))
ansr=0.d0
allocate(fxind(1:Nx))
!fxind=0.d0 this is not needed
if (abs(def).GT.1) GOTO 200
NI=4; Nd=2
Nc=2; Mb=1
Nx=1
allocate(BIG(1:Ntime+Nc,1:Ntime+Nc))
allocate(xc(1:Nc,1:Nx))
allocate(ex(1:Ntime+Nc))
ex=0.d0
xc(1,1)=u
xc(2,1)=u
! INFIN = INTEGER, array of integration limits flags: size 1 x Nb (in)
! if INFIN(I) < 0, Ith limits are (-infinity, infinity);
! if INFIN(I) = 0, Ith limits are (-infinity, Hup(I)];
! if INFIN(I) = 1, Ith limits are [Hlo(I), infinity);
! if INFIN(I) = 2, Ith limits are [Hlo(I), Hup(I)].
if (def.GT.0) then
INFIN(1:2) = 1
INFIN(3) = 0
a_up(1,1)= u+XtInf
a_lo(1,1)= u
a_up(1,2)= XdInf
a_lo(1,3)=-XdInf
else
INFIN(1:2) = 0
INFIN(3) = 1
a_up(1,1)=u
a_lo(1,1)=u-XtInf
a_lo(1,2)=-XdInf
a_up(1,3)= XdInf
endif
!print *,'Nstart',Nstart
Nstart=MAX(2,Nstart)
!print *,'Nstart',Nstart
if (ALLOCATED(COV)) then
open (unit=11, file='COV.out', STATUS='unknown')
write(11,*) 0.d0
endif
do Ntd=Nstart,Ntime
!CALL COV_INPUT2(BIG,Ntd, R0,R1,R2)
CALL COV_INPUT(BIG,Ntd,-1,R0,R1,R2,R3,R4) ! positive wave period
Nt=Ntd-Nd;
indI(2)=Nt;
indI(3)=Nt+1;
indI(4)=Ntd;
Ntdc=Ntd+Nc;
! IF (Ntd.GT.5.AND.(INIT)) THEN
! INIT=.FALSE.
! CALL INITDATA(speed)
! ENDIF
!if (SCIS.gt.1) Nj=Nt
!if (SCIS.gt.0) then
! if (SCIS.EQ.2) then
! Nj=max(Nt,0)
! else
! Nj=min(max(Nt-5, 0),0)
! endif
!endif
!Ex=0.d0
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),xc,
& Nt,indI(1:NI),a_lo(1:Mb,1:NI-1),a_up(1:Mb,1:NI-1),
& INFIN(1:NI-1))
ansr(Ntd,1)=fxind(1)*CC
if (ALLOCATED(COV)) then !SCIS.GT.0
write(11,*) COV(1) ! save coefficient of variation
endif
print *,'Ready: ',Ntd,' of ',Ntime
enddo
if (ALLOCATED(COV)) then
close(11)
endif
goto 300
200 continue
XddInf=10.d0*SQRT(R4(1))
NI=7; Nd=3
Nc=4; Mb=2
allocate(BIG(1:Ntime+Nc+1,1:Ntime+Nc+1))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:Ntime+Nc+1))
ex=0.d0
xc(1,1:Nx)=h(1:Nx)
xc(2,1:Nx)=u
xc(3,1:Nx)=u
xc(4,1:Nx)=0.d0
! INFIN = INTEGER, array of integration limits flags: size 1 x Nb (in)
! if INFIN(I) < 0, Ith limits are (-infinity, infinity);
! if INFIN(I) = 0, Ith limits are (-infinity, Hup(I)];
! if INFIN(I) = 1, Ith limits are [Hlo(I), infinity);
! if INFIN(I) = 2, Ith limits are [Hlo(I), Hup(I)].
if (def.GT.0) then
INFIN(2)=-1
INFIN(4)=0
INFIN(5)=1
INFIN(6)=0
a_up(2,1)=1.d0 !*h
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(2,2)=1.d0 ! *h
a_lo(2,2)=1.d0 ! *h
a_up(2,3)=1.d0 !*h
a_lo(1,3)=u
a_lo(1,4)=-XddInf
a_up(1,5)= XdInf
a_lo(1,6)=-XdInf
else !def<0
INFIN(2)=-1
INFIN(4)=1
INFIN(5)=0
INFIN(6)=1
a_up(1,1)=u
a_lo(2,1)=1.d0 !*h
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(2,2)=1.d0 ! *h
a_lo(2,2)=1.d0 ! *h
a_up(1,3)=u
a_lo(2,3)=1.d0 !*h
a_up(1,4)=XddInf
a_lo(1,5)=-XdInf
a_up(1,6)=XdInf
endif
EPSOLD=ABSEPS
Nstart=MAX(Nstart,3)
do tn=Nstart,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
! IF (Ntd.GT.5.AND.INIT) THEN
! INIT=.FALSE.
! CALL INITDATA(speed)
! ENDIF
!if (SCIS.gt.1) Nj=Nt
!if (SCIS.gt.0) then
! if (SCIS.EQ.2) then
! Nj=max(Nt,0)
! else
! Nj=min(max(Nt-5, 0),0)
! endif
!endif
ABSEPS=MIN(SQRT(DBLE(tn))*EPSOLD*0.5D0,0.1D0)
do ts=2,FLOOR(DBLE(tn+1)/2.d0)
!print *,'ts,tn' ,ts,tn
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2,R3,R4) ! positive wave period
indI(2)=ts-2
indI(3)=ts-1
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
!print *,'sp call rind'
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),xc,
& Nt,indI(1:NI),a_lo(1:Mb,1:NI-1),a_up(1:Mb,1:NI-1),
& INFIN(1:NI-1))
!CALL echo(BIG(1:Ntdc,1:min(7,Ntdc)),Ntdc)
!print *,'sp rind finished',fxind
!goto 900
SELECT CASE (ABS(def))
CASE (:2)
! 2, gives half wave period and wave crest amplitude (Tc,Ac).
! -2, gives half wave period and wave trough amplitude (Tt,At).
if (ts .EQ.tn-ts+1) then
ansr(tn,1:Nx)=ansr(tn,1:Nx)+fxind*CC*dt
else
ansr(tn,1:Nx)=ansr(tn,1:Nx)+fxind*CC*2.d0*dt
endif
CASE (3)
! 3, gives crest front period and wave crest amplitude (Tcf,Ac).
! -3, gives trough back period and wave trough amplitude (Ttb,At).
ansr(ts,1:Nx)=ansr(ts,1:Nx)+fxind*CC*dT
if ((ts.LT.tn-ts+1)) THEN
ansr(tn-ts+1,1:Nx)=ansr(tn-ts+1,1:Nx)+fxind*CC*dT ! exploiting the symmetry
endif
CASE (4:)
! 4, gives minimum of crest front/back period and wave crest amplitude (min(Tcf,Tcb),Ac).
! -4, gives minimum of trough front/back period and wave trough amplitude (min(Ttf,Ttb),At).
if (ts .EQ.tn-ts+1) then
ansr(ts,1:Nx)=ansr(ts,1:Nx)+fxind*CC*dt
else
ansr(ts,1:Nx)=ansr(ts,1:Nx)+fxind*CC*2.0*dt
endif
end select
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime, ' ABSEPS = ', ABSEPS
enddo !tn
!print *,'ansr',ansr
300 open (unit=11, file='dens.out', STATUS='unknown')
!print *, ansr
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansr(ts,ph)
! write(11,111) ansr(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansr)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
if (allocated(R3)) then
deallocate(R3)
deallocate(R4)
deallocate(h)
ENDIF
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,def,Ntime,Nstart,speed,SCIS,seed1,Nx,dT,rateLHD)
IMPLICIT NONE
integer, intent(out):: def,Ntime,Nstart,speed,Nx,SCIS,seed1,
& rateLHD
double precision ,intent(out) :: U,dT
double precision :: XSPLT
integer :: NIT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) def
READ (14,*) Ntime
READ (14,*) Nstart
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx
READ (14,*) dT
READ (14,*) rateLHD
READ (14,*) XSPLT
if (abs(def).GT.1) then
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
else
Nx=1
if (Ntime.lt.2) then
print *,'The number of wavelength points is too small, stop'
stop
end if
endif
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h,def,Nx)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h
integer, intent(in) :: def
integer, intent(in) :: Nx
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx
READ (4,*) H(ix)
enddo
CLOSE(UNIT=4)
!if (def.LT.0) THEN
! H=-H
!endif
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,def,R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
double precision, dimension(:),intent(out) :: R3,R4
integer,intent(in) :: Ntime,def
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
if (abs(def).GT.1) then
open (unit=4, file='Cd3.in',STATUS='unknown')
open (unit=5, file='Cd4.in',STATUS='unknown')
do i=1,Ntime
read(4,*) R3(i)
read(5,*) R4(i)
enddo
close(4)
close(5)
endif
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2,R3,R4)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
double precision, dimension(:),intent(in) :: R3,R4
integer ,intent(in) :: tn,ts
integer :: i,j,shft,Ntd1,N !=Ntdc
! the order of the variables in the covariance matrix
! are organized as follows:
! For ts>1:
! ||X(t2)..X(ts),..X(tn-1)||X''(ts) X'(t1) X'(tn)||X(ts) X(t1) X(tn) X'(ts)||
! = [Xt Xd Xc]
!
! For ts<=1:
! ||X(t2)..,..X(tn-1)||X'(t1) X'(tn)||X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
if (ts.LE.1) THEN
Ntd1=tn
N=Ntd1+2;
shft=0 ! def=1 want only crest period Tc
else
Ntd1=tn+1
N=Ntd1+4
shft=1 ! def=2 or 3 want Tc Ac or Tcf, Ac
endif
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1+shft) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+2+shft) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X' (t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X' (tn))
enddo
!call echo(big(1:tn,1:tn),tn)
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
!cov(Xc)
BIG(Ntd1+1+shft,Ntd1+1+shft) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+1+shft,Ntd1+2+shft) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+2+shft,Ntd1+2+shft) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1+shft) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+2+shft) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+1+shft) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+2+shft) =-R1(tn) !cov(X'(t1),X(tn))
if (ts.GT.1) then
!
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+1,Ntd1+2) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+1,Ntd1+3) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(X(ts),X'(ts))
BIG(Ntd1+2,Ntd1+4) = R1(ts) ! cov(X(t1),X'(ts))
BIG(Ntd1+3,Ntd1+4) = -R1(tn+1-ts) !cov(X(tn),X'(ts))
BIG(Ntd1+4,Ntd1+4) = -R2(1) ! cov(X'(ts),X'(ts))
!cov(Xd)
BIG(Ntd1-2,Ntd1-1) = -R3(ts) !cov(X''(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = R4(1)
BIG(Ntd1-2,Ntd1 ) = R3(tn+1-ts) !cov(X''(ts),X'(tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+4) =-R2(tn+1-ts) !cov(X'(tn),X'(ts))
BIG(Ntd1 ,Ntd1+1) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+4) =-R2(ts) !cov(X'(t1),X'(ts))
BIG(Ntd1-1,Ntd1+1) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+1) = R2(1) !cov(X''(ts),X (ts)
BIG(Ntd1-2,Ntd1+2) = R2(ts) !cov(X''(ts),X (t1))
BIG(Ntd1-2,Ntd1+3) = R2(tn+1-ts) !cov(X''(ts),X (tn))
BIG(Ntd1-2,Ntd1+4) = 0.d0 !cov(X''(ts),X'(ts))
!cov(Xt,Xc)
do i=1,tn-2
j=abs(i+1-ts)
BIG(i,Ntd1+1) = R0(j+1) !cov(X(ti+1),X(ts))
BIG(i,Ntd1+4) = sign(R1(j+1),R1(j+1)*dble(ts-i-1)) !cov(X(ti+1),X'(ts)) ! check this
!Cov(Xt,Xd)=cov(X(ti+1),X(ts))
BIG(i,Ntd1-2) = R2(j+1) !cov(X(ti+1),X''(ts))
enddo
endif ! ts>1
!call echo(big(1:N,1:N),N)
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
BIG(i,j) =BIG(j,i)
enddo
!call echo(big(1:N,1:N),N)
enddo
!call echo(big(1:N,1:N),N)
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2thpdf

@ -1,505 +0,0 @@
PROGRAM sp2tthpdf
C***********************************************************************
C This program computes upper and lower bounds for the: *
C *
C density of T= T_1+T_2 in a gaussian process i.e. *
C *
C wavelengthes for crests <h1 and troughs >h2 *
C *
C Sylvie and Igor 7 dec. 1999 *
C***********************************************************************
use GLOBALDATA, only : Nt,Nj,Nd,Nc,Ntd,Ntdc,NI,Mb,
& NIT,Nx,TWOPI,XSPLT,SCIS,NSIMmax,COV
use rind
IMPLICIT NONE
double precision, dimension(:,:),allocatable :: BIG
double precision, dimension(:,:),allocatable :: ansrup
double precision, dimension(:,:),allocatable :: ansrlo
double precision, dimension(: ),allocatable :: ex,CY1,CY2
double precision, dimension(:,:),allocatable :: xc
double precision, dimension(:,:),allocatable ::fxind
double precision, dimension(: ),allocatable :: h1,h2
double precision, dimension(: ),allocatable :: hh1,hh2
double precision, dimension(: ),allocatable :: R0,R1,R2
double precision ::CC,U,XddInf,XdInf,XtInf
double precision, dimension(:,:),allocatable :: a_up,a_lo
integer , dimension(: ),allocatable :: seed
integer ,dimension(7) :: indI
integer :: Ntime,N0,tn,ts,speed,ph,seed1,seed_size,Nx1,Nx2
integer :: icy,icy2
double precision :: ds,dT ! lag spacing for covariances
! DIGITAL:
! f90 -g2 -C -automatic -o ~/WAT/V4/sp2tthpdf.exe rind48.f sp2tthpdf.f
! SOLARIS:
!f90 -g -O -w3 -Bdynamic -fixed -o ../sp2tthpdf.exe rind48.f sp2tthpdf.f
!print *,'enter sp2thpdf'
CALL INIT_LEVELS(U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
!print *,'U,Ntime,NIT,speed,SCIS,seed1,Nx,dT'
!print *,U,Ntime,NIT,speed,SCIS,seed1,Nx,dT
!Nx1=1
!Nx2=1
Nx=Nx1*Nx2
!print *,'NN',Nx1,Nx2,Nx
!XSPLT=1.5d0
if (SCIS.GT.0) then
allocate(COV(1:Nx))
call random_seed(SIZE=seed_size)
allocate(seed(seed_size))
call random_seed(GET=seed(1:seed_size)) ! get current seed
seed(1)=seed1 ! change seed
call random_seed(PUT=seed(1:seed_size))
deallocate(seed)
endif
CALL INITDATA(speed)
!print *,ntime,speed,u,NIT
allocate(R0(1:Ntime+1))
allocate(R1(1:Ntime+1))
allocate(R2(1:Ntime+1))
allocate(h1(1:Nx1))
allocate(h2(1:Nx2))
CALL INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
CALL INIT_COVARIANCES(Ntime,R0,R1,R2)
allocate(hh1(1:Nx))
allocate(hh2(1:Nx))
!h transformation
do icy=1,Nx1
do icy2=1,Nx2
hh1((icy-1)*Nx2+icy2)=h1(icy);
hh2((icy-1)*Nx2+icy2)=h2(icy2);
enddo
enddo
Nj=0
indI(1)=0
C ***** The bound 'infinity' is set to 10*sigma *****
XdInf=10.d0*SQRT(-R2(1))
XtInf=10.d0*SQRT(R0(1))
!h1(1)=XtInf
!h2(1)=XtInf
! normalizing constant
CC=TWOPI*SQRT(-R0(1)/R2(1))*exp(u*u/(2.d0*R0(1)) )
allocate(CY1(1:Nx))
allocate(CY2(1:Nx))
do icy=1,Nx
CY1(icy)=exp(-0.5*hh1(icy)*hh1(icy)/100)/(10*sqrt(twopi))
CY2(icy)=exp(-0.5*hh2(icy)*hh2(icy)/100)/(10*sqrt(twopi))
enddo
!print *,CY1
allocate(ansrup(1:Ntime,1:Nx))
allocate(ansrlo(1:Ntime,1:Nx))
ansrup=0.d0
ansrlo=0.d0
allocate(fxind(1:Nx,1:2))
!fxind=0.d0 this is not needed
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Y={X(t2)..,X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)} !!
! = [Xt Xd Xc] !!
! !!
! Nt=tn-2, Nd=3, Nc=2+3 !!
! !!
! Xt= contains Nt time points in the indicator function !!
! Xd= " Nd derivatives !!
! Xc= " Nc variables to condition on !!
! (Y1,Y2) dummy variables ind. of all other v. inputing h1,h2 into rindd !!
! !!
! There are 6 ( NI=7) regions with constant bariers: !!
! (indI(1)=0); for i\in (indI(1),indI(2)] u<Y(i)<h1 !!
! (indI(2)=ts-2); for i\in (indI(2),indI(2)], inf<Y(i)<inf (no restr.) !!
! (indI(3)=ts-1); for i\in (indI(3),indI(4)], h2 <Y(i)<u !!
! (indI(4)=Nt) ; for i\in (indI(4),indI(5)], Y(i)<0 (deriv. X'(ts)) !!
! (indI(5)=Nt+1); for i\in (indI(5),indI(6)], Y(i)>0 (deriv. X'(t1)) !!
! (indI(6)=Nt+2); for i\in (indI(6),indI(7)], Y(i)>0 (deriv. X'(tn)) !!
! (indI(7)=Nt+3); NI=7. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NI=7; Nd=3
Nc=5; Mb=3
allocate(a_up(1:Mb,1:(NI-1)))
allocate(a_lo(1:Mb,1:(NI-1)))
a_up=0.d0
a_lo=0.d0
allocate(BIG(1:(Ntime+Nc+1),1:(Ntime+Nc+1)))
ALLOCATE(xc(1:Nc,1:Nx))
allocate(ex(1:(Ntime+Nc+1)))
!print *,size(ex),Ntime
ex=0.d0
!print *,size(ex),ex
xc(1,1:Nx)=hh1(1:Nx)
xc(2,1:Nx)=hh2(1:Nx)
xc(3,1:Nx)=u
xc(4,1:Nx)=u
xc(5,1:Nx)=u
! upp- down- upp-crossings at t1,ts,tn
a_lo(1,1)=u
a_up(1,2)=XtInf ! X(ts) is redundant
a_lo(1,2)=-Xtinf
a_up(1,3)=u
a_lo(1,4)=-XdInf
a_up(1,5)= XdInf
a_up(1,6)= XdInf
a_up(2,1)=1.d0
a_lo(3,3)=1.d0 !signe a voir!!!!!!
! print *,a_up
! print *,a_lo
do tn=N0,Ntime,1
! do tn=Ntime,Ntime,1
Ntd=tn+1
Nt=Ntd-Nd
Ntdc=Ntd+Nc
indI(4)=Nt
indI(5)=Nt+1
indI(6)=Nt+2
indI(7)=Ntd
if (SCIS.gt.0) then
if (SCIS.EQ.2) then
Nj=max(Nt,0)
else
Nj=min(max(Nt-5, 0),0)
endif
endif
do ts=3,tn-2
!print *,'ts,tn' ,ts,tn,Ntdc
CALL COV_INPUT(Big(1:Ntdc,1:Ntdc),tn,ts,R0,R1,R2)!positive wave period
indI(2)=ts-2
indI(3)=ts-1
CALL RINDD(fxind,Big(1:Ntdc,1:Ntdc),ex(1:Ntdc),
& xc,indI,a_lo,a_up)
ds=dt
do icy=1,Nx
! ansr(tn,:)=ansr(tn,:)+fxind*CC*ds./(CY1.*CY2)
ansrup(tn,icy)=ansrup(tn,icy)+fxind(icy,1)*CC*ds
& /(CY1(icy)*CY2(icy))
ansrlo(tn,icy)=ansrlo(tn,icy)+fxind(icy,2)*CC*ds
& /(CY1(icy)*CY2(icy))
enddo
enddo ! ts
print *,'Ready: ',tn,' of ',Ntime
enddo !tn
300 open (unit=11, file='dens.out', STATUS='unknown')
do ts=1,Ntime
do ph=1,Nx
write(11,*) ansrup(ts,ph),ansrlo(ts,ph)!,hh1(ph),hh2(ph)
! write(11,111) ansrup(ts,ph),ansrlo(ts,ph)
enddo
enddo
!111 FORMAT(2x,F12.8)
close(11)
900 deallocate(big)
deallocate(fxind)
deallocate(ansrup)
deallocate(ansrlo)
deallocate(xc)
deallocate(ex)
deallocate(R0)
deallocate(R1)
deallocate(R2)
if (allocated(COV) ) then
deallocate(COV)
endif
deallocate(h1)
deallocate(h2)
deallocate(hh1)
deallocate(hh2)
deallocate(a_up)
deallocate(a_lo)
stop
!return
CONTAINS
SUBROUTINE INIT_LEVELS
& (U,Ntime,N0,NIT,speed,SCIS,seed1,Nx1,Nx2,dT)
IMPLICIT NONE
integer, intent(out):: Ntime,N0,NIT,speed,Nx1,Nx2,SCIS,seed1
double precision ,intent(out) :: U,dT
OPEN(UNIT=14,FILE='reflev.in',STATUS= 'UNKNOWN')
READ (14,*) U
READ (14,*) Ntime
READ (14,*) N0
READ (14,*) NIT
READ (14,*) speed
READ (14,*) SCIS
READ (14,*) seed1
READ (14,*) Nx1,Nx2
READ (14,*) dT
if (Ntime.lt.3) then
print *,'The number of wavelength points is too small, stop'
stop
end if
CLOSE(UNIT=14)
RETURN
END SUBROUTINE INIT_LEVELS
C******************************************************
SUBROUTINE INIT_AMPLITUDES(h1,Nx1,h2,Nx2)
IMPLICIT NONE
double precision, dimension(:), intent(out) :: h1,h2
integer, intent(in) :: Nx1,Nx2
integer :: ix
OPEN(UNIT=4,FILE='h.in',STATUS= 'UNKNOWN')
C
C Reading in amplitudes
C
do ix=1,Nx1
READ (4,*) H1(ix)
enddo
do ix=1,Nx2
READ (4,*) H2(ix)
enddo
CLOSE(UNIT=4)
RETURN
END SUBROUTINE INIT_AMPLITUDES
C**************************************************
C***********************************************************************
C***********************************************************************
SUBROUTINE INIT_COVARIANCES(Ntime,R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:),intent(out) :: R0,R1,R2
integer,intent(in) :: Ntime
integer :: i
open (unit=1, file='Cd0.in',STATUS='unknown')
open (unit=2, file='Cd1.in',STATUS='unknown')
open (unit=3, file='Cd2.in',STATUS='unknown')
do i=1,Ntime
read(1,*) R0(i)
read(2,*) R1(i)
read(3,*) R2(i)
enddo
close(1)
close(2)
close(3)
return
END SUBROUTINE INIT_COVARIANCES
C***********************************************************************
C***********************************************************************
C**********************************************************************
SUBROUTINE COV_INPUT(BIG,tn,ts, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:),intent(inout) :: BIG
double precision, dimension(:),intent(in) :: R0,R1,R2
integer ,intent(in) :: tn,ts
integer :: i,j,Ntd1,N !=Ntdc
double precision :: tmp
! the order of the variables in the covariance matrix
! are organized as follows:
!
! ||X(t2)..X(ts),..X(tn-1)||X'(ts) X'(t1) X'(tn)||Y1 Y2 X(ts) X(t1) X(tn)||
! = [Xt Xd Xc]
! where
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
! Computations of all covariances follows simple rules: Cov(X(t),X(s))=r(t,s),
! then Cov(X'(t),X(s))=dr(t,s)/dt. Now for stationary X(t) we have
! a function r(tau) such that Cov(X(t),X(s))=r(s-t) (or r(t-s) will give the same result).
!
! Consequently Cov(X'(t),X(s)) = -r'(s-t) = -sign(s-t)*r'(|s-t|)
! Cov(X'(t),X'(s)) = -r''(s-t) = -r''(|s-t|)
! Cov(X''(t),X'(s)) = r'''(s-t) = sign(s-t)*r'''(|s-t|)
! Cov(X''(t),X(s)) = r''(s-t) = r''(|s-t|)
! Cov(X''(t),X''(s)) = r''''(s-t) = r''''(|s-t|)
Ntd1=tn+1
N=Ntd1+Nc
do i=1,tn-2
!cov(Xt)
do j=i,tn-2
BIG(i,j) = R0(j-i+1) ! cov(X(ti+1),X(tj+1))
enddo
!cov(Xt,Xc)
BIG(i ,Ntd1+1) = 0.d0 !cov(X(ti+1),Y1)
BIG(i ,Ntd1+2) = 0.d0 !cov(X(ti+1),Y2)
BIG(i ,Ntd1+4) = R0(i+1) !cov(X(ti+1),X(t1))
BIG(tn-1-i ,Ntd1+5) = R0(i+1) !cov(X(t.. ),X(tn))
!Cov(Xt,Xd)=cov(X(ti+1),x(tj)
BIG(i,Ntd1-1) =-R1(i+1) !cov(X(ti+1),X'(t1))
BIG(tn-1-i,Ntd1)= R1(i+1) !cov(X(ti+1),X'(tn))
enddo
!cov(Xd)
BIG(Ntd1 ,Ntd1 ) = -R2(1)
BIG(Ntd1-1,Ntd1 ) = -R2(tn) !cov(X'(t1),X'(tn))
BIG(Ntd1-1,Ntd1-1) = -R2(1)
BIG(Ntd1-2,Ntd1-1) = -R2(ts) !cov(X'(ts),X'(t1))
BIG(Ntd1-2,Ntd1-2) = -R2(1)
BIG(Ntd1-2,Ntd1 ) = -R2(tn+1-ts) !cov(X'(ts),X'(tn))
!cov(Xc)
BIG(Ntd1+1,Ntd1+1) = 100.d0 ! cov(Y1 Y1)
BIG(Ntd1+1,Ntd1+2) = 0.d0 ! cov(Y1 Y2)
BIG(Ntd1+1,Ntd1+3) = 0.d0 ! cov(Y1 X(ts))
BIG(Ntd1+1,Ntd1+4) = 0.d0 ! cov(Y1 X(t1))
BIG(Ntd1+1,Ntd1+5) = 0.d0 ! cov(Y1 X(tn))
BIG(Ntd1+2,Ntd1+2) = 100.d0 ! cov(Y2 Y2)
BIG(Ntd1+2,Ntd1+3) = 0.d0 ! cov(Y2 X(ts))
BIG(Ntd1+2,Ntd1+4) = 0.d0 ! cov(Y2 X(t1))
BIG(Ntd1+2,Ntd1+5) = 0.d0 ! cov(Y2 X(tn))
BIG(Ntd1+3,Ntd1+3) = R0(1) ! cov(X(ts),X (ts)
BIG(Ntd1+3,Ntd1+4) = R0(ts) ! cov(X(ts),X (t1))
BIG(Ntd1+3,Ntd1+5) = R0(tn+1-ts) ! cov(X(ts),X (tn))
BIG(Ntd1+4,Ntd1+4) = R0(1) ! cov(X(t1),X (t1))
BIG(Ntd1+4,Ntd1+5) = R0(tn) ! cov(X(t1),X (tn))
BIG(Ntd1+5,Ntd1+5) = R0(1) ! cov(X(tn),X (tn))
!cov(Xd,Xc)
BIG(Ntd1 ,Ntd1+1) = 0.d0 !cov(X'(tn),Y1)
BIG(Ntd1 ,Ntd1+2) = 0.d0 !cov(X'(tn),Y2)
BIG(Ntd1-1 ,Ntd1+1) = 0.d0 !cov(X'(t1),Y1)
BIG(Ntd1-1 ,Ntd1+2) = 0.d0 !cov(X'(t1),Y2)
BIG(Ntd1-2 ,Ntd1+1) = 0.d0 !cov(X'(ts),Y1)
BIG(Ntd1-2 ,Ntd1+2) = 0.d0 !cov(X'(ts),Y2)
BIG(Ntd1 ,Ntd1+4) = R1(tn) !cov(X'(tn),X(t1))
BIG(Ntd1 ,Ntd1+5) = 0.d0 !cov(X'(tn),X(tn))
BIG(Ntd1-1,Ntd1+4) = 0.d0 !cov(X'(t1),X(t1))
BIG(Ntd1-1,Ntd1+5) =-R1(tn) !cov(X'(t1),X(tn))
BIG(Ntd1 ,Ntd1+3) = R1(tn+1-ts) !cov(X'(tn),X (ts))
BIG(Ntd1-1,Ntd1+3) =-R1(ts) !cov(X'(t1),X (ts))
BIG(Ntd1-2,Ntd1+3) = 0.d0 !cov(X'(ts),X (ts)
BIG(Ntd1-2,Ntd1+4) = R1(ts) !cov(X'(ts),X (t1))
BIG(Ntd1-2,Ntd1+5) = -R1(tn+1-ts) !cov(X'(ts),X (tn))
do i=1,tn-2
j=abs(i+1-ts)
!cov(Xt,Xc)
BIG(i,Ntd1+3) = R0(j+1) !cov(X(ti+1),X(ts))
!Cov(Xt,Xd)
if ((i+1-ts).lt.0) then
BIG(i,Ntd1-2) = R1(j+1)
else !cov(X(ti+1),X'(ts))
BIG(i,Ntd1-2) = -R1(j+1)
endif
enddo
! make lower triangular part equal to upper
do j=1,N-1
do i=j+1,N
tmp =BIG(j,i)
BIG(i,j)=tmp
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT
SUBROUTINE COV_INPUT2(BIG,pt, R0,R1,R2)
IMPLICIT NONE
double precision, dimension(:,:), intent(out) :: BIG
double precision, dimension(:), intent(in) :: R0,R1,R2
integer :: pt,i,j
! the order of the variables in the covariance matrix
! are organized as follows;
! X(t2)...X(tn-1) X'(t1) X'(tn) X(t1) X(tn) = [Xt Xd Xc]
!
! where Xd is the derivatives
!
! Xt= time points in the indicator function
! Xd= derivatives
! Xc=variables to condition on
!cov(Xc)
BIG(pt+2,pt+2) = R0(1)
BIG(pt+1,pt+1) = R0(1)
BIG(pt+1,pt+2) = R0(pt)
!cov(Xd)
BIG(pt,pt) = -R2(1)
BIG(pt-1,pt-1) = -R2(1)
BIG(pt-1,pt) = -R2(pt)
!cov(Xd,Xc)
BIG(pt,pt+2) = 0.d0
BIG(pt,pt+1) = R1(pt)
BIG(pt-1,pt+2) = -R1(pt)
BIG(pt-1,pt+1) = 0.d0
if (pt.GT.2) then
!cov(Xt)
do i=1,pt-2
do j=i,pt-2
BIG(i,j) = R0(j-i+1)
enddo
enddo
!cov(Xt,Xc)
do i=1,pt-2
BIG(i,pt+1) = R0(i+1)
BIG(pt-1-i,pt+2) = R0(i+1)
enddo
!Cov(Xt,Xd)=cov(X(ti+1),x(tj))
do i=1,pt-2
BIG(i,pt-1) = -R1(i+1)
BIG(pt-1-i,pt)= R1(i+1)
enddo
endif
! make lower triangular part equal to upper
do j=1,pt+1
do i=j+1,pt+2
BIG(i,j)=BIG(j,i)
enddo
enddo
C write (*,10) ((BIG(j,i),i=N+1,N+6),j=N+1,N+6)
C 10 format(6F8.4)
RETURN
END SUBROUTINE COV_INPUT2
END PROGRAM sp2tthpdf

@ -1,30 +0,0 @@
"""
f2py c_library.pyf c_functions.c -c
gfortran -W -Wall -pedantic-errors -fbounds-check -Werror -c dsvdc.f mregmodule.f
"""
import os
import sys
from wafo.f2py_tools import f2py_call_str
def compile_all():
f2py_call = f2py_call_str()
print '=' * 75
print 'compiling cov2mod'
print '=' * 75
files = ['dsvdc', 'mregmodule', 'intfcmod']
compile1_format = 'gfortran -fPIC -c %s.f'
format1 = '%s.o ' * len(files)
for file_ in files:
os.system(compile1_format % file_)
file_objects = format1 % tuple(files)
os.system(f2py_call + ' -m cov2mod -c %s cov2mmpdfreg_intfc.f' %
file_objects)
if __name__ == '__main__':
compile_all()

@ -1,651 +0,0 @@
C Version 1994-X-18
C This is a new version of WAMP program computing crest-trough wavelength
C and amplitude density.
C
C revised pab 2007
C -moved all common blocks into modules
C -renamed from minmax to sp2mmpdfreg + fixed some bugs
C revised pab July 2007
! -renamed from sp2mmpdfreg to cov2mmpdfreg
PROGRAM cov2mmpdfreg
USE SIZEMOD
USE EPSMOD
USE CHECKMOD
USE MREGMOD
IMPLICIT NONE
real*8 Q0,SQ0,Q1,SQ1, AA, BB, DAI, AI , U,V,VV, XL0, XL2, XL4
REAL*8 VDERI, CDER,SDER, DER, CONST, F, HHHH,FM, VALUE
C INTEGER, PARAMETER :: MMAX = 5, NMAX = 101, RDIM = 10201
REAL*8, DIMENSION(NMAX) :: HHT,T,Ulev,Vlev,VT,UT,Vdd,Udd
REAL*8, DIMENSION(RDIM) :: R,R1,R2,R3
REAL*8, DIMENSION(5*NMAX) :: COV
REAL*8, DIMENSION(NMAX,NMAX) :: UVdens
C DIMENSION UVdens(NMAX,NMAX),HHT(NMAX)
C DIMENSION T(NMAX),Ulev(NMAX),Vlev(NMAX)
C DIMENSION VT(NMAX),UT(NMAX),Vdd(NMAX),Udd(NMAX)
C DIMENSION COV(5*NMAX),R(RDIM),R1(RDIM),R2(RDIM),R3(RDIM)
DIMENSION AA(MMAX-2,MMAX-2),BB(MMAX+1),DAI(MMAX),AI((MMAX+1)*NMAX)
C
C The program computes the joint density of maximum the following minimum
C and the distance between Max and min for a zero-mean stationary
C Gaussian process with covariance function defined explicitely with 4
C derivatives. The process should be normalized so that the first and
C the second spectral moments are equal to 1. The values of Max are taken
C as the nodes at Hermite-Quadrature and then integrated out so that
C the output is a joint density of wavelength T and amplitude H=Max-min.
C The Max values are defined by subroutine Gauss_M with the accuracy
C input epsu. The principle is that the integral of the marginal density
C of f_Max is computed with sufficient accuracy.
C
REAL*8, DIMENSION(NMAX) :: B0,DB0,DDB0,B1,DB1,DDB1,DB2,DDB2
REAL*8, DIMENSION(NMAX) :: Q,SQ,VDER,DBI,BI
C DIMENSION B0(NMAX),DB0(NMAX),DDB0(NMAX)
C DIMENSION B1(NMAX),DB1(NMAX),DDB1(NMAX)
C DIMENSION DB2(NMAX),DDB2(NMAX)
C DIMENSION Q(NMAX),SQ(NMAX),VDER(NMAX),DBI(NMAX),BI(NMAX)
INTEGER :: J,I,I1,I2,I3,IU, IV, NU,NV,NG,N,NIT, NNIT, INF
INTEGER :: fffff
C REAL*8 EPS0
C INTEGER III01,III11,III21,III31,III41,III51
C *,III61,III71,III81,III91,III101 , III0
C COMMON/CHECK1/III01,III11,III21,III31,III41,III51
C *,III61,III71,III81,III91,III101
C COMMON/CHECKQ/III0
C COMMON /EPS/ EPS,EPSS,CEPSS
C
C Initiation of all constants and integration nodes 'INITINTEG'
C
CALL INITINTEG(NIT)
c
c OBS. we are using the variables R,R1,R2 R3 as a temporary storage
C for transformation g of the process.
c
CALL INITLEVELS(Ulev,NU,Vlev,NV,T,HHT,N,R1,R2,NG)
IF( R1(1) .gt. R1(ng)) then
do 13 I=1,ng
R3(I)=R1(I)
R(I) =R2(I)
13 continue
do 17 i=1,ng
R1(i) = R3(ng-i+1)
R2(i) = R(ng-i+1)
17 continue
end if
if(abs(R1(ng)-R1(1))*abs(R2(ng)-R2(1)).lt.0.01d0) then
print *,'The transformation g is singular, stop'
stop
end if
DO 14 IV=1,Nv
V=Vlev(IV)
CALL TRANSF(NG,V,R2,R1,VALUE,DER)
VT(IV)=VALUE
Vdd(IV)=DER
14 continue
DO 16 IU=1,Nu
U = Ulev(IU)
CALL TRANSF(NG,U,R2,R1,VALUE,DER)
UT(IU) = VALUE
Udd(IU) = DER
do 16 IV=1,Nv
UVdens(IU,IV)=0.0d0
16 CONTINUE
CALL COVG(XL0,XL2,XL4,COV,R1,R2,R3,T,N)
Q0=XL4
IF (Q0.le.1.0D0+EPS) then
Print *,'Covariance structure is singular, stop.'
stop
end if
SQ0 = SQRT(Q0)
Q1 = XL0-XL2*XL2/XL4
IF (Q1.le.eps) then
Print *,'Covariance structure is singular, stop.'
stop
end if
SQ1 = SQRT(Q1)
DO 10 I=1,N
B0(I) =-COV(I+2*N)
DB0(I) =-COV(I+3*N)
DDB0(I)=-COV(I+4*N)
B1(I) =COV(I)+COV(I+2*N)*(XL2/XL4)
DB1(I) =COV(I+N)+COV(I+3*N)*(XL2/XL4)
DDB1(I)=COV(I+2*N)+XL2*(COV(I+4*N)/XL4)
C
C Q(I) contains Var(X(T(i))|X'(0),X''(0),X(0))
C VDER(I) contains Var(X''(T(i))|X'(0),X''(0),X(0))
C
Q(I)=XL0 - COV(I+N)*(COV(I+N)/XL2) - B0(I)*(B0(I)/Q0)
1 -B1(I)*(B1(I)/Q1)
VDER(I)=XL4 - (COV(I+3*N)*COV(I+3*N))/XL2 - (DDB0(I)*DDB0(I))/Q0
1 - (DDB1(I)*DDB1(I))/Q1
C
C DDB2(I) contains Cov(X''(T(i)),X(T(i))|X'(0),X''(0),X(0))
C
DDB2(I)=-XL2 - (COV(I+N)*COV(I+3*N))/XL2 - DDB0(I)*(B0(I)/Q0)
1 -DDB1(I)*(B1(I)/Q1)
IF(Q(I).LE.eps) then
SQ(i) =0.0d0
DDB2(i)=0.0d0
else
SQ(I)=SQRT(Q(I))
C
C VDER(I) contains Var(X''(T(i))|X'(0),X''(0),X(0),X(T(i))
C
VDER(I)=VDER(I) - (DDB2(I)*DDB2(I))/Q(I)
end if
10 CONTINUE
DO 15 I=1,N
DO 15 J=1,N
C
C R1 contains Cov(X(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R1(J+(I-1)*N)=R1(J+(I-1)*N) - COV(I+N)*(COV(J+2*N)/XL2)
1 - (B0(I)*DB0(J)/Q0) - (B1(I)*DB1(J)/Q1)
C
C R2 contains Cov(X'(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R2(J+(I-1)*N) = -R2(J+(I-1)*N) - COV(I+2*N)*(COV(J+2*N)/XL2)
1 - DB0(I)*DB0(J)/Q0 - DB1(I)*(DB1(J)/Q1)
C
C R3 contains Cov(X''(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R3(J+(I-1)*N) = R3(J+(I-1)*N) - COV(I+3*N)*(COV(J+2*N)/XL2)
1 - DB0(J)*(DDB0(I)/Q0) - DDB1(I)*(DB1(J)/Q1)
15 CONTINUE
C The initiations are finished and we are beginning with 3 loops
C on T=T(I), U=Ulevels(IU), V=Ulevels(IV), U>V.
DO 20 I=1,N
NNIT=NIT
IF (Q(I).LE.EPS) GO TO 20
DO 30 I1=1,I
DB2(I1)=R1(I1+(I-1)*N)
C Cov(X'(T(I1)),X(T(i))|X'(0),X''(0),X(0))
C DDB2(I) contains Cov(X''(T(i)),X(T(i))|X'(0),X''(0),X(0))
30 CONTINUE
DO 50 I3=1,I
DBI(I3) = R3(I3+(I-1)*N) - (DDB2(I)*DB2(I3)/Q(I))
BI(I3) = R2(I3+(I-1)*N) - (DB2(I)*DB2(I3)/Q(I))
50 CONTINUE
DO 51 I3=1,I-1
AI(I3)=0.0d0
AI(I3+I-1)=DB0(I3)/SQ0
AI(I3+2*(I-1))=DB1(I3)/SQ1
AI(I3+3*(I-1))=DB2(I3)/SQ(I)
51 CONTINUE
VDERI=VDER(I)
DAI(1)=0.0d0
DAI(2)=DDB0(I)/SQ0
DAI(3)=DDB1(I)/SQ1
DAI(4)=DDB2(I)/SQ(I)
AA(1,1)=DB0(I)/SQ0
AA(1,2)=DB1(I)/SQ1
AA(1,3)=DB2(I)/SQ(I)
AA(2,1)=XL2/SQ0
AA(2,2)=SQ1
AA(2,3)=0.0d0
AA(3,1)=B0(I)/SQ0
AA(3,2)=B1(I)/SQ1
AA(3,3)=SQ(I)
IF (BI(I).LE.EPS) NNIT=0
IF (NNIT.GT.1) THEN
IF(I.LT.1) GO TO 41
DO 40 I1=1,I-1
DO 40 I2=1,I-1
C R contains Cov(X'(T(I1)),X'(T(I2))|X'(0),X''(0),X(0),X(I))
R(I2+(I1-1)*(I-1))=R2(I2+(I1-1)*N)-(DB2(I1)*DB2(I2)/Q(I))
40 CONTINUE
41 CONTINUE
END IF
C Here the covariance of the problem would be innitiated
INF=0
Print *,' Laps to go:',N-I+1
DO 80 IV=1,Nv
V=VT(IV)
! IF (ABS(V).GT.5.0D0) GO TO 80
IF (Vdd(IV).LT.EPS0) GO TO 80
DO 60 IU=1,Nu
U=UT(IU)
IF (U.LE.V) go to 60
! IF (ABS(U).GT.5.0D0) GO TO 60
IF (Udd(IU).LT.EPS0) GO TO 60
BB(1)=0.0d0
BB(2)=U
BB(3)=V
! if (IV.EQ.2.AND.IU.EQ.1) THEN
! fffff = 10
! endif
CALL MREG(F,R,BI,DBI,AA,BB,AI,DAI,VDERI,3,I-1,NNIT,INF)
INF=1
UVdens(IU,IV) = UVdens(IU,IV) + Udd(IU)*Vdd(IV)*HHT(I)*F
! if (F.GT.0.01.AND.U.GT.2.AND.V.LT.-2) THEN
! if (N-I+1 .eq. 38.and.IV.EQ.26.AND.IU.EQ.16) THEN
! if (IV.EQ.32.AND.IU.EQ.8.and.I.eq.11) THEN
! PRINT * ,' R:', R(1:I)
! PRINT * ,' BI:', BI(1:I)
! PRINT * ,' DBI:', DBI(1:I)
! PRINT * ,' DB2:', DB2(1:I)
! PRINT * ,' DB0(1):', DB0(1)
! PRINT * ,' DB1(1):', DB1(1)
! PRINT * ,' DAI:', DAI
! PRINT * ,' BB:', BB
! PRINT * ,' VDERI:', VDERI
! PRINT * ,' F :', F
! PRINT * ,' UVDENS :', UVdens(IU,IV)
! fffff = 10
! endif
60 CONTINUE
80 continue
20 CONTINUE
hhhh=0.0d0
do 90 Iu=1,Nu
do 90 Iv=1,Nv
WRITE(10,300) Ulev(iu),Vlev(iv),UVdens(iu,iv)
hhhh=hhhh+UVdens(iu,iv)
90 continue
if (nu.gt.1.and.nv.gt.1) then
write(11,*) 'SumSum f_uv *du*dv='
1,(Ulev(2)-Ulev(1))*(Vlev(2)-Vlev(1))*hhhh
end if
C sder=sqrt(XL4-XL2*XL2/XL0)
C cder=-XL2/sqrt(XL0)
C const=1/sqrt(XL0*XL4)
C DO 95 IU=1,NU
C U=UT(IU)
C FM=Udd(IU)*const*exp(-0.5*U*U/XL0)*PMEAN(-cder*U,sder)
C WRITE(9,300) Ulev(IU),FM
C 95 continue
C DO 105 IV=1,NV
C V=VT(IV)
C VV=cder*V
C Fm=Vdd(IV)*const*exp(-0.5*V*V/XL0)*PMEAN(VV,sder)
C WRITE(8,300) Vlev(IV),Fm
C 105 continue
if (III0.eq.0) III0=1
write(11,*) 'Rate of calls RINDT0:',float(iii01)/float(III0)
write(11,*) 'Rate of calls RINDT1:',float(iii11)/float(III0)
write(11,*) 'Rate of calls RINDT2:',float(iii21)/float(III0)
write(11,*) 'Rate of calls RINDT3:',float(iii31)/float(III0)
write(11,*) 'Rate of calls RINDT4:',float(iii41)/float(III0)
write(11,*) 'Rate of calls RINDT5:',float(iii51)/float(III0)
write(11,*) 'Rate of calls RINDT6:',float(iii61)/float(III0)
write(11,*) 'Rate of calls RINDT7:',float(iii71)/float(III0)
write(11,*) 'Rate of calls RINDT8:',float(iii81)/float(III0)
write(11,*) 'Rate of calls RINDT9:',float(iii91)/float(III0)
write(11,*) 'Rate of calls RINDT10:',float(iii101)/float(III0)
write(11,*) 'Number of calls of RINDT*',III0
CLOSE(UNIT=8)
CLOSE(UNIT=9)
CLOSE(UNIT=10)
CLOSE(UNIT=11)
300 FORMAT(4(3X,F10.6))
STOP
END
SUBROUTINE INITLEVELS(ULEVELS,NU,Vlevels,Nv,T,HT,N,TG,XG,NG)
USE TBRMOD
USE SIZEMOD
IMPLICIT NONE
C INTEGER, PARAMETER:: NMAX = 101, RDIM = 10201
C DIMENSION ULEVELS(1),Vlevels(1),T(1),HT(1),TG(1),XG(1),HH(101)
REAL*8, DIMENSION(NMAX), intent(inout) :: ULEVELS,Vlevels,T,HT
REAL*8, DIMENSION(RDIM), intent(inout) :: TG,XG
INTEGER, intent(inout) :: NG
REAL*8 :: UMIN,UMAX,VMIN,VMAX, HU,HV
integer :: N, I, NU, NV
C REAL*8, DIMENSION(NMAX) :: HH
C COMMON/TBR/HH
OPEN(UNIT=2,FILE='transf.in')
OPEN(UNIT=4,FILE='Mm.in')
OPEN(UNIT=3,FILE='t.in')
NG=1
12 READ (2,*,END=11) TG(NG),XG(NG)
NG=NG+1
GO TO 12
11 CONTINUE
NG=NG-1
IF (NG.GT.501) THEN
PRINT *,'Vector defining transformation of data > 501, stop'
STOP
END IF
N=1
32 READ (3,*,END=31) T(N)
N=N+1
GO TO 32
31 CONTINUE
N=N-1
CLOSE(UNIT=3)
IF(N.ge.NMAX) then
print *,'The number of wavelength points >',NMAX-1, ' stop'
stop
end if
IF(N.lt.2) then
print *,'The number of wavelength points < 2, stop'
stop
end if
HT(1)=0.5d0*(T(2)-T(1))
HT(N)=0.5d0*(T(N)-T(N-1))
HH(1)=-100.0d0
HH(N)=-100.0d0
DO 10 I=2,N-1
HT(I)=0.5d0*(T(I+1)-T(I-1))
HH(I)=-100.0d0
10 CONTINUE
READ(4,*) Umin,Umax,NU
READ(4,*) Vmin,Vmax,NV
IF(NU.gt.NMAX) then
print *,'The number of maxima >',NMAX,' stop'
stop
end if
IF(NV.gt.NMAX) then
print *,'The number of minima >',NMAX,' stop'
stop
end if
IF(NU.LT.1) Then
print *,'The number of maxima < 1, stop'
stop
end if
IF(NV.LT.1) Then
print *,'The number of minima < 1, stop'
stop
end if
Ulevels(1)=Umax
IF (NU.lt.2) go to 25
HU=(Umax-Umin)/DBLE(NU-1)
DO 20 I=1,NU-1
ULEVELS(I+1)=Umax-DBLE(I)*HU
20 CONTINUE
25 continue
Vlevels(1)=Vmax
IF (NV.lt.2) go to 35
HV=(Vmax-Vmin)/DBLE(NV-1)
DO 30 I=1,Nv-1
VLEVELS(I+1)=Vmax-DBLE(I)*HV
30 CONTINUE
35 continue
CLOSE(UNIT=4)
RETURN
END
SUBROUTINE TRANSF(N,T,A,TIMEV,VALUE,DER)
C
C N number of data points
C TIMEV vector of time points
C A a vector of values of a function G(TIME)
C T independent time point
C VALUE is a value of a function at T, i.e. VALUE=G(T).
c DER=G'(t)
C
USE SIZEMOD
IMPLICIT NONE
REAL*8, intent(inout):: VALUE, DER,T
C INTEGER, PARAMETER :: RDIM = 10201
REAL*8, DIMENSION(RDIM), intent(in) :: A,TIMEV
integer, intent(in) :: N
REAL*8:: T1
integer :: I
IF (T.LT.TIMEV(1)) then
der=(A(2)-A(1))/(TIMEV(2)-TIMEV(1))
T1=T-TIMEV(1)
VALUE=A(1)+T1*DER
return
end if
IF (T.GT.TIMEV(N)) then
der = (A(N)-A(N-1))/(TIMEV(N)-TIMEV(N-1))
T1 = T-TIMEV(N)
VALUE=A(N)+T1*DER
return
end if
DO 5 I=2,N
IF (T.LT.TIMEV(I)) GO TO 10
5 CONTINUE
10 I=I-1
T1=T-TIMEV(I)
DER=(A(I+1)-A(I))/(TIMEV(i+1)-TIMEV(I))
VALUE=A(I)+T1*DER
RETURN
END
REAL*8 FUNCTION SPLE(N,T,A,TIMEV)
C
C N number of data points
C TIME vector of time points
C A a vector of values of a function G(TIME)
C T independent time point
C SPLE is a value of a function at T, i.e. SPLE=G(T).
C
USE SIZEMOD
IMPLICIT NONE
INTEGER, INTENT(IN):: N
REAL*8, INTENT(IN) :: T
REAL*8, DIMENSION(5*NMAX), INTENT(IN) :: A,TIMEV
REAL*8 :: T1
INTEGER :: I
SPLE=-9.9d0
IF (T.LT.TIMEV(1) .OR. T.GT.TIMEV(N)) RETURN
DO 5 I=2,N
IF (T.LT.TIMEV(I)) GO TO 10
5 CONTINUE
10 I=I-1
T1=T-TIMEV(I)
SPLE=A(I)+T1*(A(I+1)-A(I))/(TIMEV(i+1)-TIMEV(I))
RETURN
END
SUBROUTINE COVG(XL0,XL2,XL4,COV,COV1,COV2,COV3,T,N)
C
C COVG evaluates:
C
C XL0,XL2,XL4 - spectral moments.
C
C Covariance function and its four derivatives for a vector T of length N.
C It is saved in a vector COV; COV(1,...,N)=r(T), COV(N+1,...,2N)=r'(T), etc.
C The vector COV should be of the length 5*N.
C
C Covariance matrices COV1=r'(T-T), COV2=r''(T-T) and COV3=r'''(T-T)
C Dimension of COV1, COV2 should be N*N.
C
USE SIZEMOD
! IMPLICIT NONE
C INTEGER, PARAMETER:: NMAX = 101, RDIM = 10201
REAL*8, PARAMETER:: ZERO = 0.0d0
REAL*8, intent(inout) :: XL0,XL2,XL4
REAL*8, DIMENSION(5*NMAX), intent(inout) :: COV
REAL*8, DIMENSION(5*NMAX) :: A, TIMEV
REAL*8, DIMENSION(RDIM), intent(inout) :: COV1,COV2,COV3
REAL*8, DIMENSION(NMAX), intent(in) :: T
INTEGER, intent(in) :: N
integer :: NT, I, J, II
REAL*8 :: TT, T0
OPEN(UNIT=32,FILE='Cd0.in')
OPEN(UNIT=33,FILE='Cd1.in')
OPEN(UNIT=34,FILE='Cd2.in')
OPEN(UNIT=35,FILE='Cd3.in')
OPEN(UNIT=36,FILE='Cd4.in')
C
C COV(Y(T),Y(0))
C
NT=1
12 READ (32,*,END=11) TIMEV(NT),A(NT)
NT=NT+1
GO TO 12
11 CONTINUE
NT=NT-1
XL0=SPLE(NT,ZERO,A,TIMEV)
DO 10 I=1,N
COV(I)=SPLE(NT,T(I),A,TIMEV)
10 CONTINUE
C
C DERIVATIVE COV(Y(T),Y(0))
C
NT=1
22 READ (33,*,END=21) TIMEV(NT),A(NT)
NT=NT+1
GO TO 22
21 CONTINUE
NT=NT-1
II=0
DO 20 I=1,N
COV(I+N)=SPLE(NT,T(I),A,TIMEV)
DO 20 J=1,N
II=II+1
T0=T(J)-T(I)
TT=ABS(T0)
COV1(II)=SPLE(NT,TT,A,TIMEV)
IF (T0.LT.0.0d0) COV1(II)=-COV1(II)
20 CONTINUE
C 2-DERIVATIVE COV(Y(T),Y(0))
NT=1
32 READ (34,*,END=31) TIMEV(NT),A(NT)
NT=NT+1
GO TO 32
31 CONTINUE
NT=NT-1
II=0
XL2=-SPLE(NT,ZERO,A,TIMEV)
DO 30 I=1,N
COV(I+2*N)=SPLE(NT,T(I),A,TIMEV)
DO 30 J=1,N
II=II+1
TT=ABS(T(J)-T(I))
COV2(II)=SPLE(NT,TT,A,TIMEV)
30 CONTINUE
C 3-DERIVATIVE COV(Y(T),Y(0))
NT=1
42 READ (35,*,END=41) TIMEV(NT),A(NT)
NT=NT+1
GO TO 42
41 CONTINUE
NT=NT-1
II=0
DO 40 I=1,N
COV(I+3*N)=SPLE(NT,T(I),A,TIMEV)
DO 40 J=1,N
II=II+1
T0=T(J)-T(I)
TT=ABS(T0)
COV3(II)=SPLE(NT,TT,A,TIMEV)
IF (T0.LT.0.0d0) COV3(II)=-COV3(II)
40 CONTINUE
C 4-DERIVATIVE COV(Y(T),Y(0))
NT=1
52 READ (36,*,END=51) TIMEV(NT),A(NT)
NT=NT+1
GO TO 52
51 CONTINUE
NT=NT-1
XL4=SPLE(NT,ZERO,A,TIMEV)
DO 50 I=1,N
COV(I+4*N)=SPLE(NT,T(I),A,TIMEV)
50 CONTINUE
CLOSE(UNIT=32)
CLOSE(UNIT=33)
CLOSE(UNIT=34)
CLOSE(UNIT=35)
CLOSE(UNIT=36)
RETURN
END
SUBROUTINE INITINTEG(NIT)
USE RINTMOD
USE EPSMOD
USE INFCMOD
USE MREGMOD
! IMPLICIT NONE
INTEGER, intent(inout) :: NIT
! INTEGER ISQ1
C dimension INF(10),INFO(10)
C COMMON /RINT/ C,FC
C COMMON /EPS/ EPS,EPSS,CEPSS
C COMMON /INFC/ ISQ,INF,INFO
OPEN(UNIT=1,FILE='accur.in')
OPEN(UNIT=8,FILE='min.out')
OPEN(UNIT=9,FILE='Max.out')
OPEN(UNIT=10,FILE='Maxmin.out')
OPEN(UNIT=11,FILE='Maxmin.log')
READ(1,*) NIT,IAC,ISQ
READ(1,*) EPS,EPSS,EPS0
CLOSE (UNIT=1)
FC=FI(C)-FI(-C)
CEPSS=1.0d0-EPSS
RETURN
END

@ -1,370 +0,0 @@
C Version 1994-X-18
C This is a new version of WAMP program computing crest-trough wavelength
C and amplitude density.
C
C revised pab 2007
C -moved all common blocks into modules
C -renamed from minmax to sp2mmpdfreg + fixed some bugs
C revised pab July 2007
! -renamed from sp2mmpdfreg to cov2mmpdfreg
! gfortran -W -Wall -pedantic-errors -fbounds-check -Werror -c dsvdc.f mregmodule.f cov2mmpdfreg.f
SUBROUTINE INITINTEG(EPS_,EPSS_,EPS0_,C_,IAC_,ISQ_)
! Initiation of all constants and integration nodes 'INITINTEG'
USE RINTMOD
USE EPSMOD
USE INFCMOD
USE MREGMOD
REAL*8 :: EPS_,EPSS_,EPS0_,C_
INTEGER :: IAC_,ISQ_
Cf2py real*8, optional :: EPS_ = 0.01
Cf2py real*8, optional :: EPSS_ = 0.00005
Cf2py real*8, optional :: EPS0_ = 0.00005
Cf2py real*8, optional :: C_ = 4.5
Cf2py integer, optional :: IAC_ = 1
Cf2py integer, optional :: ISQ_ = 0
! IMPLICIT NONE
C COMMON /RINT/ C,FC
C COMMON /EPS/ EPS,EPSS,CEPSS
C COMMON /INFC/ ISQ,INF,INFO
IAC = IAC_
ISQ = ISQ_
EPS = EPS_
EPSS = EPSS_
EPS0 = EPS0_
C = C_
FC = FI(C)-FI(-C)
! CEPSS = 1.0d0-EPSS
RETURN
END SUBROUTINE INITINTEG
subroutine cov2mmpdfreg(UVdens,t,COV,ULev,VLev,Tg,Xg,Nt,Nu,Nv,Ng,
& NIT)
USE SIZEMOD
USE EPSMOD
USE CHECKMOD
USE MREGMOD
USE INTFCMOD
IMPLICIT NONE
INTEGER, INTENT(IN) :: Nt, Nu, Nv, Ng, NIT
REAL*8, DIMENSION(Nt,5), intent(in):: COV
REAL*8, DIMENSION(Nu,Nv), intent(out):: UVdens
REAL*8, DIMENSION(Nu), intent(in):: ULev
REAL*8, DIMENSION(Nv), intent(in):: VLev
REAL*8, DIMENSION(Ng), intent(in):: Tg, Xg
REAL*8, dimension(Nt), intent(in):: T
Cf2py integer, intent(hide), depend(t) :: Nt = len(t)
Cf2py integer, intent(hide), depend(Ulev) :: Nu = len(Ulev)
Cf2py integer, intent(hide), depend(Vlev) :: Nv = len(Vlev)
Cf2py integer, intent(hide), depend(Tg) :: Ng = len(Tg)
Cf2py integer, optional :: NIT = 2
Cf2py real*8, intent(out), depend(Nu,Nv) :: UVdens
Cf2py depend(Ng) Xg
Cf2py depend(Nt,5) COV
real*8 Q0,SQ0,Q1,SQ1, U,V, XL0, XL2, XL4
REAL*8 VDERI, DER, F, HHHH, VALUE
C REAL*8 VV, CDER,SDER, CONST1, FM
C INTEGER, PARAMETER :: MMAX = 5, NMAX = 101, RDIM = 10201
REAL*8, DIMENSION(NMAX) :: HHT,VT,UT,Vdd,Udd
REAL*8, DIMENSION(RDIM) :: R,R1,R2,R3
REAL*8:: AA(MMAX-2,MMAX-2),AI((MMAX+1)*NMAX)
REAL*8, DIMENSION(MMAX+1) :: BB, DAI
C DIMENSION UVdens(NMAX,NMAX),HHT(NMAX)
C DIMENSION T(NMAX),Ulev(NMAX),Vlev(NMAX)
C DIMENSION VT(NMAX),UT(NMAX),Vdd(NMAX),Udd(NMAX)
C DIMENSION COV(5*NMAX),R(RDIM),R1(RDIM),R2(RDIM),R3(RDIM)
C
C The program computes the joint density of maximum the following minimum
C and the distance between Max and min for a zero-mean stationary
C Gaussian process with covariance function defined explicitely with 4
C derivatives. The process should be normalized so that the first and
C the second spectral moments are equal to 1. The values of Max are taken
C as the nodes at Hermite-Quadrature and then integrated out so that
C the output is a joint density of wavelength T and amplitude H=Max-min.
C The Max values are defined by subroutine Gauss_M with the accuracy
C input epsu. The principle is that the integral of the marginal density
C of f_Max is computed with sufficient accuracy.
C
REAL*8, DIMENSION(NMAX) :: B0,DB0,DDB0,B1,DB1,DDB1,DB2,DDB2
REAL*8, DIMENSION(NMAX) :: Q,SQ,VDER,DBI,BI
C DIMENSION B0(NMAX),DB0(NMAX),DDB0(NMAX)
C DIMENSION B1(NMAX),DB1(NMAX),DDB1(NMAX)
C DIMENSION DB2(NMAX),DDB2(NMAX)
C DIMENSION Q(NMAX),SQ(NMAX),VDER(NMAX),DBI(NMAX),BI(NMAX)
INTEGER :: J,I,I1,I2,I3,IU, IV,N, NNIT, INF
C INTEGER :: fffff
C REAL*8 EPS0
C INTEGER III01,III11,III21,III31,III41,III51
C *,III61,III71,III81,III91,III101 , III0
C COMMON/CHECK1/III01,III11,III21,III31,III41,III51
C *,III61,III71,III81,III91,III101
C COMMON/CHECKQ/III0
C COMMON /EPS/ EPS,EPSS,CEPSS
C
C Initiation of all constants and integration nodes 'INITINTEG'
C
! CALL INITINTEG()
! OPEN(UNIT=8,FILE='min.out')
! OPEN(UNIT=9,FILE='Max.out')
! OPEN(UNIT=10,FILE='Maxmin.out')
! OPEN(UNIT=11,FILE='Maxmin.log')
c
c OBS. we are using the variables R,R1,R2 R3 as a temporary storage
C for transformation g of the process.
N = Nt
CALL INITLEVELS(T,HHT,Nt,NU,Nv)
C CALL INITLEVELS(Ulev,NU,Vlev,NV,T,HHT,Nt,R1,R2,NG)
IF( Tg(1) .gt. Tg(ng)) then
print *,'Error Tg must be strictly increasing'
return
end if
if(abs(Tg(ng)-Tg(1))*abs(Xg(ng)-Xg(1)).lt.0.01d0) then
print *,'The transformation g is singular, stop'
return
end if
! do IV=1,Nt
! print *, 'Cov', COV(IV,:)
! end do
DO IV=1,Nv
V=Vlev(IV)
CALL TRANSF(NG,V,Xg,Tg,VALUE,DER)
VT(IV)=VALUE
Vdd(IV)=DER
enddo
DO IU=1,Nu
U = Ulev(IU)
CALL TRANSF(NG,U,Xg,Tg,VALUE,DER)
UT(IU) = VALUE
Udd(IU) = DER
do IV=1,Nv
UVdens(IU,IV)=0.0d0
enddo
enddo
CALL COVG(XL0,XL2,XL4,R1,R2,R3,COV,T,Nt)
Q0=XL4
IF (Q0.le.1.0D0+EPS) then
Print *,'Covariance structure is singular, stop.'
return
end if
SQ0 = SQRT(Q0)
Q1 = XL0-XL2*XL2/XL4
IF (Q1.le.EPS) then
Print *,'Covariance structure is singular, stop.'
return
end if
SQ1 = SQRT(Q1)
DO I=1,Nt
B0(I) =-COV(I,3)
DB0(I) =-COV(I,4)
DDB0(I)=-COV(I,5)
B1(I) =COV(I,1)+COV(I,3)*(XL2/XL4)
DB1(I) =COV(I,2)+COV(I,4)*(XL2/XL4)
DDB1(I)=COV(I,3)+XL2*(COV(I,5)/XL4)
C
C Q(I) contains Var(X(T(i))|X'(0),X''(0),X(0))
C VDER(I) contains Var(X''(T(i))|X'(0),X''(0),X(0))
C
Q(I)=XL0 - COV(I,2)*(COV(I,2)/XL2) - B0(I)*(B0(I)/Q0)
1 -B1(I)*(B1(I)/Q1)
VDER(I)=XL4 - (COV(I,4)*COV(I,4))/XL2 - (DDB0(I)*DDB0(I))/Q0
1 - (DDB1(I)*DDB1(I))/Q1
C
C DDB2(I) contains Cov(X''(T(i)),X(T(i))|X'(0),X''(0),X(0))
C
DDB2(I)=-XL2 - (COV(I,2)*COV(I,4))/XL2 - DDB0(I)*(B0(I)/Q0)
1 -DDB1(I)*(B1(I)/Q1)
IF(Q(I).LE.eps) then
SQ(i) =0.0d0
DDB2(i)=0.0d0
else
SQ(I)=SQRT(Q(I))
C
C VDER(I) contains Var(X''(T(i))|X'(0),X''(0),X(0),X(T(i))
C
VDER(I)=VDER(I) - (DDB2(I)*DDB2(I))/Q(I)
end if
c10 CONTINUE
enddo
DO I=1,Nt
DO J=1,Nt
C
C R1 contains Cov(X(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R1(J+(I-1)*N) = R1(J+(I-1)*N) - COV(I,2)*(COV(J,3)/XL2)
1 - (B0(I)*DB0(J)/Q0) - (B1(I)*DB1(J)/Q1)
C
C R2 contains Cov(X'(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R2(J+(I-1)*N) = -R2(J+(I-1)*N) - COV(I,3)*(COV(J,3)/XL2)
1 - DB0(I)*DB0(J)/Q0 - DB1(I)*(DB1(J)/Q1)
C
C R3 contains Cov(X''(T(I)),X'(T(J))|X'(0),X''(0),X(0))
C
R3(J+(I-1)*N) = R3(J+(I-1)*N) - COV(I,4)*(COV(J,3)/XL2)
1 - DB0(J)*(DDB0(I)/Q0) - DDB1(I)*(DB1(J)/Q1)
c15 CONTINUE
enddo
enddo
C The initiations are finished and we are beginning with 3 loops
C on T=T(I), U=Ulevels(IU), V=Ulevels(IV), U>V.
DO I=1,Nt
NNIT=NIT
IF (Q(I).LE.EPS) GO TO 20
DO I1=1,I
DB2(I1)=R1(I1+(I-1)*N)
C Cov(X'(T(I1)),X(T(i))|X'(0),X''(0),X(0))
C DDB2(I) contains Cov(X''(T(i)),X(T(i))|X'(0),X''(0),X(0))
enddo
DO I3=1,I
DBI(I3) = R3(I3+(I-1)*N) - (DDB2(I)*DB2(I3)/Q(I))
BI(I3) = R2(I3+(I-1)*N) - (DB2(I)*DB2(I3)/Q(I))
enddo
DO I3=1,I-1
AI(I3)=0.0d0
AI(I3+I-1)=DB0(I3)/SQ0
AI(I3+2*(I-1))=DB1(I3)/SQ1
AI(I3+3*(I-1))=DB2(I3)/SQ(I)
enddo
VDERI=VDER(I)
DAI(1)=0.0d0
DAI(2)=DDB0(I)/SQ0
DAI(3)=DDB1(I)/SQ1
DAI(4)=DDB2(I)/SQ(I)
AA(1,1)=DB0(I)/SQ0
AA(1,2)=DB1(I)/SQ1
AA(1,3)=DB2(I)/SQ(I)
AA(2,1)=XL2/SQ0
AA(2,2)=SQ1
AA(2,3)=0.0d0
AA(3,1)=B0(I)/SQ0
AA(3,2)=B1(I)/SQ1
AA(3,3)=SQ(I)
IF (BI(I).LE.EPS) NNIT=0
IF (NNIT.GT.1) THEN
IF(I.LT.1) GO TO 41
DO I1=1,I-1
DO I2=1,I-1
C R contains Cov(X'(T(I1)),X'(T(I2))|X'(0),X''(0),X(0),X(I))
R(I2+(I1-1)*(I-1))=R2(I2+(I1-1)*N)-(DB2(I1)*DB2(I2)/Q(I))
enddo
enddo
41 CONTINUE
END IF
C Here the covariance of the problem would be initiated
INF=0
Print *,' Laps to go:',Nt-I+1
DO IV=1,Nv
V=VT(IV)
! IF (ABS(V).GT.5.0D0) GO TO 80
IF (Vdd(IV).LT.EPS0) GO TO 80
DO IU=1,Nu
U=UT(IU)
IF (U.LE.V) go to 60
! IF (ABS(U).GT.5.0D0) GO TO 60
IF (Udd(IU).LT.EPS0) GO TO 60
BB(1)=0.0d0
BB(2)=U
BB(3)=V
! if (IV.EQ.2.AND.IU.EQ.1) THEN
! fffff = 10
! endif
CALL MREG(F,R,BI,DBI,AA,BB,AI,DAI,VDERI,3,I-1,NNIT,INF)
INF=1
UVdens(IU,IV) = UVdens(IU,IV) + Udd(IU)*Vdd(IV)*HHT(I)*F
! if (F.GT.0.01.AND.U.GT.2.AND.V.LT.-2) THEN
! if (N-I+1 .eq. 38.and.IV.EQ.26.AND.IU.EQ.16) THEN
! if (IV.EQ.32.AND.IU.EQ.8.and.I.eq.11) THEN
! PRINT * ,' R:', R(1:I)
! PRINT * ,' BI:', BI(1:I)
! PRINT * ,' DBI:', DBI(1:I)
! PRINT * ,' DB2:', DB2(1:I)
! PRINT * ,' DB0(1):', DB0(1)
! PRINT * ,' DB1(1):', DB1(1)
! PRINT * ,' DAI:', DAI
! PRINT * ,' BB:', BB
! PRINT * ,' VDERI:', VDERI
! PRINT * ,' F :', F
! PRINT * ,' UVDENS :', UVdens(IU,IV)
! fffff = 10
! endif
60 CONTINUE
enddo
80 continue
enddo
20 CONTINUE
enddo
hhhh=0.0d0
do Iu=1,Nu
do Iv=1,Nv
! WRITE(10,300) Ulev(iu),Vlev(iv),UVdens(iu,iv)
hhhh=hhhh+UVdens(iu,iv)
enddo
enddo
if (nu.gt.1.and.nv.gt.1) then
VALUE = (Ulev(2)-Ulev(1))*(Vlev(2)-Vlev(1))*hhhh
print *,'SumSum f_uv *du*dv=', VALUE
end if
C sder=sqrt(XL4-XL2*XL2/XL0)
C cder=-XL2/sqrt(XL0)
C const1=1/sqrt(XL0*XL4)
C DO 95 IU=1,NU
C U=UT(IU)
C FM=Udd(IU)*const1*exp(-0.5*U*U/XL0)*PMEAN(-cder*U,sder)
C WRITE(9,300) Ulev(IU),FM
C 95 continue
C DO 105 IV=1,NV
C V=VT(IV)
C VV=cder*V
C Fm=Vdd(IV)*const1*exp(-0.5*V*V/XL0)*PMEAN(VV,sder)
C WRITE(8,300) Vlev(IV),Fm
C 105 continue
if (III0.eq.0) III0=1
PRINT *, 'Rate of calls RINDT0:',float(iii01)/float(III0)
PRINT *, 'Rate of calls RINDT1:',float(iii11)/float(III0)
PRINT *, 'Rate of calls RINDT2:',float(iii21)/float(III0)
PRINT *, 'Rate of calls RINDT3:',float(iii31)/float(III0)
PRINT *, 'Rate of calls RINDT4:',float(iii41)/float(III0)
PRINT *, 'Rate of calls RINDT5:',float(iii51)/float(III0)
PRINT *, 'Rate of calls RINDT6:',float(iii61)/float(III0)
PRINT *, 'Rate of calls RINDT7:',float(iii71)/float(III0)
PRINT *, 'Rate of calls RINDT8:',float(iii81)/float(III0)
PRINT *, 'Rate of calls RINDT9:',float(iii91)/float(III0)
PRINT *, 'Rate of calls RINDT10:',float(iii101)/float(III0)
PRINT *, 'Number of calls of RINDT*',III0
return
END subroutine cov2mmpdfreg

@ -1,613 +0,0 @@
MODULE SVD
IMPLICIT NONE
INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(12, 60)
! Based upon routines from the NSWC (Naval Surface Warfare Center),
! which were based upon LAPACK routines.
! Code converted using TO_F90 by Alan Miller
! Date: 2003-11-11 Time: 17:50:44
! Revised pab 2007
! Converted to fixed form
CONTAINS
SUBROUTINE drotg(da, db, dc, ds)
! DESIGNED BY C.L.LAWSON, JPL, 1977 SEPT 08
!
! CONSTRUCT THE GIVENS TRANSFORMATION
!
! ( DC DS )
! G = ( ) , DC**2 + DS**2 = 1 ,
! (-DS DC )
!
! WHICH ZEROS THE SECOND ENTRY OF THE 2-VECTOR (DA,DB)**T .
!
! THE QUANTITY R = (+/-)SQRT(DA**2 + DB**2) OVERWRITES DA IN
! STORAGE. THE VALUE OF DB IS OVERWRITTEN BY A VALUE Z WHICH
! ALLOWS DC AND DS TO BE RECOVERED BY THE FOLLOWING ALGORITHM:
! IF Z=1 SET DC=0.D0 AND DS=1.D0
! IF DABS(Z) < 1 SET DC=SQRT(1-Z**2) AND DS=Z
! IF DABS(Z) > 1 SET DC=1/Z AND DS=SQRT(1-DC**2)
!
! NORMALLY, THE SUBPROGRAM DROT(N,DX,INCX,DY,INCY,DC,DS) WILL
! NEXT BE CALLED TO APPLY THE TRANSFORMATION TO A 2 BY N MATRIX.
!
! ------------------------------------------------------------------
REAL (dp), INTENT(IN OUT) :: da
REAL (dp), INTENT(IN OUT) :: db
REAL (dp), INTENT(OUT) :: dc
REAL (dp), INTENT(OUT) :: ds
REAL (dp) :: u, v, r
IF (ABS(da) <= ABS(db)) GO TO 10
! *** HERE ABS(DA) > ABS(DB) ***
u = da + da
v = db / u
! NOTE THAT U AND R HAVE THE SIGN OF DA
r = SQRT(.25D0 + v**2) * u
! NOTE THAT DC IS POSITIVE
dc = da / r
ds = v * (dc + dc)
db = ds
da = r
RETURN
! *** HERE ABS(DA) <= ABS(DB) ***
10 IF (db == 0.d0) GO TO 20
u = db + db
v = da / u
! NOTE THAT U AND R HAVE THE SIGN OF DB
! (R IS IMMEDIATELY STORED IN DA)
da = SQRT(.25D0 + v**2) * u
! NOTE THAT DS IS POSITIVE
ds = db / da
dc = v * (ds + ds)
IF (dc == 0.d0) GO TO 15
db = 1.d0 / dc
RETURN
15 db = 1.d0
RETURN
! *** HERE DA = DB = 0.D0 ***
20 dc = 1.d0
ds = 0.d0
RETURN
END SUBROUTINE drotg
SUBROUTINE dswap1 (n, dx, dy)
! INTERCHANGES TWO VECTORS.
! USES UNROLLED LOOPS FOR INCREMENTS EQUAL ONE.
! JACK DONGARRA, LINPACK, 3/11/78.
! This version is for increments = 1.
INTEGER, INTENT(IN) :: n
REAL (dp), INTENT(IN OUT) :: dx(*)
REAL (dp), INTENT(IN OUT) :: dy(*)
REAL (dp) :: dtemp
INTEGER :: i, m, mp1
IF(n <= 0) RETURN
! CODE FOR BOTH INCREMENTS EQUAL TO 1
!
! CLEAN-UP LOOP
m = MOD(n,3)
IF( m == 0 ) GO TO 40
DO i = 1,m
dtemp = dx(i)
dx(i) = dy(i)
dy(i) = dtemp
END DO
IF( n < 3 ) RETURN
40 mp1 = m + 1
DO i = mp1,n,3
dtemp = dx(i)
dx(i) = dy(i)
dy(i) = dtemp
dtemp = dx(i + 1)
dx(i + 1) = dy(i + 1)
dy(i + 1) = dtemp
dtemp = dx(i + 2)
dx(i + 2) = dy(i + 2)
dy(i + 2) = dtemp
END DO
RETURN
END SUBROUTINE dswap1
SUBROUTINE drot1 (n, dx, dy, c, s)
! APPLIES A PLANE ROTATION.
! JACK DONGARRA, LINPACK, 3/11/78.
! This version is for increments = 1.
INTEGER, INTENT(IN) :: n
REAL (dp), INTENT(IN OUT) :: dx(*)
REAL (dp), INTENT(IN OUT) :: dy(*)
REAL (dp), INTENT(IN) :: c
REAL (dp), INTENT(IN) :: s
REAL (dp) :: dtemp
INTEGER :: i
IF(n <= 0) RETURN
! CODE FOR BOTH INCREMENTS EQUAL TO 1
DO i = 1,n
dtemp = c*dx(i) + s*dy(i)
dy(i) = c*dy(i) - s*dx(i)
dx(i) = dtemp
END DO
RETURN
END SUBROUTINE drot1
SUBROUTINE dsvdc(x, n, p, s, e, u, v, job, info)
INTEGER, INTENT(IN) :: n
INTEGER, INTENT(IN) :: p
REAL (dp), INTENT(IN OUT) :: x(:,:)
REAL (dp), INTENT(OUT) :: s(:)
REAL (dp), INTENT(OUT) :: e(:)
REAL (dp), INTENT(OUT) :: u(:,:)
REAL (dp), INTENT(OUT) :: v(:,:)
INTEGER, INTENT(IN) :: job
INTEGER, INTENT(OUT) :: info
! DSVDC IS A SUBROUTINE TO REDUCE A DOUBLE PRECISION NXP MATRIX X
! BY ORTHOGONAL TRANSFORMATIONS U AND V TO DIAGONAL FORM. THE
! DIAGONAL ELEMENTS S(I) ARE THE SINGULAR VALUES OF X. THE
! COLUMNS OF U ARE THE CORRESPONDING LEFT SINGULAR VECTORS,
! AND THE COLUMNS OF V THE RIGHT SINGULAR VECTORS.
!
! ON ENTRY
!
! X DOUBLE PRECISION(LDX,P), WHERE LDX.GE.N.
! X CONTAINS THE MATRIX WHOSE SINGULAR VALUE
! DECOMPOSITION IS TO BE COMPUTED. X IS
! DESTROYED BY DSVDC.
!
! LDX INTEGER.
! LDX IS THE LEADING DIMENSION OF THE ARRAY X.
!
! N INTEGER.
! N IS THE NUMBER OF ROWS OF THE MATRIX X.
!
! P INTEGER.
! P IS THE NUMBER OF COLUMNS OF THE MATRIX X.
!
! LDU INTEGER.
! LDU IS THE LEADING DIMENSION OF THE ARRAY U.
! (SEE BELOW).
!
! LDV INTEGER.
! LDV IS THE LEADING DIMENSION OF THE ARRAY V.
! (SEE BELOW).
!
! JOB INTEGER.
! JOB CONTROLS THE COMPUTATION OF THE SINGULAR
! VECTORS. IT HAS THE DECIMAL EXPANSION AB
! WITH THE FOLLOWING MEANING
!
! A.EQ.0 DO NOT COMPUTE THE LEFT SINGULAR VECTORS.
! A.EQ.1 RETURN THE N LEFT SINGULAR VECTORS IN U.
! A.GE.2 RETURN THE FIRST MIN(N,P) SINGULAR
! VECTORS IN U.
! B.EQ.0 DO NOT COMPUTE THE RIGHT SINGULAR VECTORS.
! B.EQ.1 RETURN THE RIGHT SINGULAR VECTORS IN V.
!
! ON RETURN
!
! S DOUBLE PRECISION(MM), WHERE MM=MIN(N+1,P).
! THE FIRST MIN(N,P) ENTRIES OF S CONTAIN THE SINGULAR
! VALUES OF X ARRANGED IN DESCENDING ORDER OF MAGNITUDE.
!
! E DOUBLE PRECISION(P).
! E ORDINARILY CONTAINS ZEROS. HOWEVER SEE THE
! DISCUSSION OF INFO FOR EXCEPTIONS.
!
! U DOUBLE PRECISION(LDU,K), WHERE LDU.GE.N. IF
! JOBA.EQ.1 THEN K.EQ.N, IF JOBA.GE.2
! THEN K.EQ.MIN(N,P).
! U CONTAINS THE MATRIX OF LEFT SINGULAR VECTORS.
! U IS NOT REFERENCED IF JOBA.EQ.0. IF N.LE.P
! OR IF JOBA.EQ.2, THEN U MAY BE IDENTIFIED WITH X
! IN THE SUBROUTINE CALL.
!
! V DOUBLE PRECISION(LDV,P), WHERE LDV.GE.P.
! V CONTAINS THE MATRIX OF RIGHT SINGULAR VECTORS.
! V IS NOT REFERENCED IF JOB.EQ.0. IF P.LE.N,
! THEN V MAY BE IDENTIFIED WITH X IN THE
! SUBROUTINE CALL.
!
! INFO INTEGER.
! THE SINGULAR VALUES (AND THEIR CORRESPONDING SINGULAR
! VECTORS) S(INFO+1),S(INFO+2),...,S(M) ARE CORRECT
! (HERE M=MIN(N,P)). THUS IF INFO.EQ.0, ALL THE
! SINGULAR VALUES AND THEIR VECTORS ARE CORRECT.
! IN ANY EVENT, THE MATRIX B = TRANS(U)*X*V IS THE
! BIDIAGONAL MATRIX WITH THE ELEMENTS OF S ON ITS DIAGONAL
! AND THE ELEMENTS OF E ON ITS SUPER-DIAGONAL (TRANS(U)
! IS THE TRANSPOSE OF U). THUS THE SINGULAR VALUES
! OF X AND B ARE THE SAME.
!
! LINPACK. THIS VERSION DATED 03/19/79 .
! G.W. STEWART, UNIVERSITY OF MARYLAND, ARGONNE NATIONAL LAB.
!
! DSVDC USES THE FOLLOWING FUNCTIONS AND SUBPROGRAMS.
!
! EXTERNAL DROT
! BLAS DAXPY,DDOT,DSCAL,DSWAP,DNRM2,DROTG
! FORTRAN DABS,DMAX1,MAX0,MIN0,MOD,DSQRT
! INTERNAL VARIABLES
INTEGER :: iter, j, jobu, k, kase, kk, l, ll, lls, lm1, lp1, ls,
& lu, m, maxit,mm, mm1, mp1, nct, nctp1, ncu, nrt, nrtp1
REAL (dp) :: t, work(n)
REAL (dp) :: b, c, cs, el, emm1, f, g, scale, shift, sl, sm, sn,
& smm1, t1, test, ztest
LOGICAL :: wantu, wantv
! SET THE MAXIMUM NUMBER OF ITERATIONS.
maxit = 30
! DETERMINE WHAT IS TO BE COMPUTED.
wantu = .false.
wantv = .false.
jobu = MOD(job,100)/10
ncu = n
IF (jobu > 1) ncu = MIN(n,p)
IF (jobu /= 0) wantu = .true.
IF (MOD(job,10) /= 0) wantv = .true.
! REDUCE X TO BIDIAGONAL FORM, STORING THE DIAGONAL ELEMENTS
! IN S AND THE SUPER-DIAGONAL ELEMENTS IN E.
info = 0
nct = MIN(n-1, p)
s(1:nct+1) = 0.0_dp
nrt = MAX(0, MIN(p-2,n))
lu = MAX(nct,nrt)
IF (lu < 1) GO TO 170
DO l = 1, lu
lp1 = l + 1
IF (l > nct) GO TO 20
! COMPUTE THE TRANSFORMATION FOR THE L-TH COLUMN AND
! PLACE THE L-TH DIAGONAL IN S(L).
s(l) = SQRT( SUM( x(l:n,l)**2 ) )
IF (s(l) == 0.0D0) GO TO 10
IF (x(l,l) /= 0.0D0) s(l) = SIGN(s(l), x(l,l))
x(l:n,l) = x(l:n,l) / s(l)
x(l,l) = 1.0D0 + x(l,l)
10 s(l) = -s(l)
20 IF (p < lp1) GO TO 50
DO j = lp1, p
IF (l > nct) GO TO 30
IF (s(l) == 0.0D0) GO TO 30
! APPLY THE TRANSFORMATION.
t = -DOT_PRODUCT(x(l:n,l), x(l:n,j)) / x(l,l)
x(l:n,j) = x(l:n,j) + t * x(l:n,l)
! PLACE THE L-TH ROW OF X INTO E FOR THE
! SUBSEQUENT CALCULATION OF THE ROW TRANSFORMATION.
30 e(j) = x(l,j)
END DO
50 IF (.NOT.wantu .OR. l > nct) GO TO 70
! PLACE THE TRANSFORMATION IN U FOR SUBSEQUENT BACK MULTIPLICATION.
u(l:n,l) = x(l:n,l)
70 IF (l > nrt) CYCLE
! COMPUTE THE L-TH ROW TRANSFORMATION AND PLACE THE
! L-TH SUPER-DIAGONAL IN E(L).
e(l) = SQRT( SUM( e(lp1:p)**2 ) )
IF (e(l) == 0.0D0) GO TO 80
IF (e(lp1) /= 0.0D0) e(l) = SIGN(e(l), e(lp1))
e(lp1:lp1+p-l-1) = e(lp1:p) / e(l)
e(lp1) = 1.0D0 + e(lp1)
80 e(l) = -e(l)
IF (lp1 > n .OR. e(l) == 0.0D0) GO TO 120
! APPLY THE TRANSFORMATION.
work(lp1:n) = 0.0D0
DO j = lp1, p
work(lp1:lp1+n-l-1) = work(lp1:lp1+n-l-1) + e(j) *
& x(lp1:lp1+n-l-1,j)
END DO
DO j = lp1, p
x(lp1:lp1+n-l-1,j) = x(lp1:lp1+n-l-1,j) - (e(j)/e(lp1)) *
& work(lp1:lp1+n-l-1)
END DO
120 IF (.NOT.wantv) CYCLE
! PLACE THE TRANSFORMATION IN V FOR SUBSEQUENT
! BACK MULTIPLICATION.
v(lp1:p,l) = e(lp1:p)
END DO
! SET UP THE FINAL BIDIAGONAL MATRIX OF ORDER M.
170 m = MIN(p,n+1)
nctp1 = nct + 1
nrtp1 = nrt + 1
IF (nct < p) s(nctp1) = x(nctp1,nctp1)
IF (n < m) s(m) = 0.0D0
IF (nrtp1 < m) e(nrtp1) = x(nrtp1,m)
e(m) = 0.0D0
! IF REQUIRED, GENERATE U.
IF (.NOT.wantu) GO TO 300
IF (ncu < nctp1) GO TO 200
DO j = nctp1, ncu
u(1:n,j) = 0.0_dp
u(j,j) = 1.0_dp
END DO
200 DO ll = 1, nct
l = nct - ll + 1
IF (s(l) == 0.0D0) GO TO 250
lp1 = l + 1
IF (ncu < lp1) GO TO 220
DO j = lp1, ncu
t = -DOT_PRODUCT(u(l:n,l), u(l:n,j)) / u(l,l)
u(l:n,j) = u(l:n,j) + t * u(l:n,l)
END DO
220 u(l:n,l) = -u(l:n,l)
u(l,l) = 1.0D0 + u(l,l)
lm1 = l - 1
IF (lm1 < 1) CYCLE
u(1:lm1,l) = 0.0_dp
CYCLE
250 u(1:n,l) = 0.0_dp
u(l,l) = 1.0_dp
END DO
! IF IT IS REQUIRED, GENERATE V.
300 IF (.NOT.wantv) GO TO 350
DO ll = 1, p
l = p - ll + 1
lp1 = l + 1
IF (l > nrt) GO TO 320
IF (e(l) == 0.0D0) GO TO 320
DO j = lp1, p
t = -DOT_PRODUCT(v(lp1:lp1+p-l-1,l),
& v(lp1:lp1+p-l-1,j)) / v(lp1,l)
v(lp1:lp1+p-l-1,j) = v(lp1:lp1+p-l-1,j) + t * v(lp1:lp1+p-l-1,l)
END DO
320 v(1:p,l) = 0.0D0
v(l,l) = 1.0D0
END DO
! MAIN ITERATION LOOP FOR THE SINGULAR VALUES.
350 mm = m
iter = 0
! QUIT IF ALL THE SINGULAR VALUES HAVE BEEN FOUND.
! ...EXIT
360 IF (m == 0) GO TO 620
! IF TOO MANY ITERATIONS HAVE BEEN PERFORMED, SET FLAG AND RETURN.
IF (iter < maxit) GO TO 370
info = m
! ......EXIT
GO TO 620
! THIS SECTION OF THE PROGRAM INSPECTS FOR NEGLIGIBLE ELEMENTS
! IN THE S AND E ARRAYS. ON COMPLETION
! THE VARIABLES KASE AND L ARE SET AS FOLLOWS.
!
! KASE = 1 IF S(M) AND E(L-1) ARE NEGLIGIBLE AND L < M
! KASE = 2 IF S(L) IS NEGLIGIBLE AND L < M
! KASE = 3 IF E(L-1) IS NEGLIGIBLE, L < M, AND
! S(L), ..., S(M) ARE NOT NEGLIGIBLE (QR STEP).
! KASE = 4 IF E(M-1) IS NEGLIGIBLE (CONVERGENCE).
370 DO ll = 1, m
l = m - ll
! ...EXIT
IF (l == 0) EXIT
test = ABS(s(l)) + ABS(s(l+1))
ztest = test + ABS(e(l))
IF (ztest /= test) CYCLE
e(l) = 0.0D0
! ......EXIT
EXIT
END DO
IF (l /= m - 1) GO TO 410
kase = 4
GO TO 480
410 lp1 = l + 1
mp1 = m + 1
DO lls = lp1, mp1
ls = m - lls + lp1
! ...EXIT
IF (ls == l) EXIT
test = 0.0D0
IF (ls /= m) test = test + ABS(e(ls))
IF (ls /= l + 1) test = test + ABS(e(ls-1))
ztest = test + ABS(s(ls))
IF (ztest /= test) CYCLE
s(ls) = 0.0D0
! ......EXIT
EXIT
END DO
IF (ls /= l) GO TO 450
kase = 3
GO TO 480
450 IF (ls /= m) GO TO 460
kase = 1
GO TO 480
460 kase = 2
l = ls
480 l = l + 1
! PERFORM THE TASK INDICATED BY KASE.
SELECT CASE ( kase )
CASE ( 1)
GO TO 490
CASE ( 2)
GO TO 520
CASE ( 3)
GO TO 540
CASE ( 4)
GO TO 570
END SELECT
! DEFLATE NEGLIGIBLE S(M).
490 mm1 = m - 1
f = e(m-1)
e(m-1) = 0.0D0
DO kk = l, mm1
k = mm1 - kk + l
t1 = s(k)
CALL drotg(t1, f, cs, sn)
s(k) = t1
IF (k == l) GO TO 500
f = -sn*e(k-1)
e(k-1) = cs*e(k-1)
500 IF (wantv) CALL drot1(p, v(1:,k), v(1:,m), cs, sn)
END DO
GO TO 610
! SPLIT AT NEGLIGIBLE S(L).
520 f = e(l-1)
e(l-1) = 0.0D0
DO k = l, m
t1 = s(k)
CALL drotg(t1, f, cs, sn)
s(k) = t1
f = -sn*e(k)
e(k) = cs*e(k)
IF (wantu) CALL drot1(n, u(1:,k), u(1:,l-1), cs, sn)
END DO
GO TO 610
! PERFORM ONE QR STEP.
!
! CALCULATE THE SHIFT.
540 scale = MAX(ABS(s(m)),ABS(s(m-1)),ABS(e(m-1)),ABS(s(l)),ABS(e(l)))
sm = s(m)/scale
smm1 = s(m-1)/scale
emm1 = e(m-1)/scale
sl = s(l)/scale
el = e(l)/scale
b = ((smm1 + sm)*(smm1 - sm) + emm1**2)/2.0D0
c = (sm*emm1)**2
shift = 0.0D0
IF (b == 0.0D0 .AND. c == 0.0D0) GO TO 550
shift = SQRT(b**2+c)
IF (b < 0.0D0) shift = -shift
shift = c/(b + shift)
550 f = (sl + sm)*(sl - sm) - shift
g = sl*el
! CHASE ZEROS.
mm1 = m - 1
DO k = l, mm1
CALL drotg(f, g, cs, sn)
IF (k /= l) e(k-1) = f
f = cs*s(k) + sn*e(k)
e(k) = cs*e(k) - sn*s(k)
g = sn*s(k+1)
s(k+1) = cs*s(k+1)
IF (wantv) CALL drot1(p, v(1:,k), v(1:,k+1), cs, sn)
CALL drotg(f, g, cs, sn)
s(k) = f
f = cs*e(k) + sn*s(k+1)
s(k+1) = -sn*e(k) + cs*s(k+1)
g = sn*e(k+1)
e(k+1) = cs*e(k+1)
IF (wantu .AND. k < n) CALL drot1(n, u(1:,k), u(1:,k+1), cs, sn)
END DO
e(m-1) = f
iter = iter + 1
GO TO 610
! CONVERGENCE.
! MAKE THE SINGULAR VALUE POSITIVE.
570 IF (s(l) >= 0.0D0) GO TO 590
s(l) = -s(l)
IF (wantv) v(1:p,l) = -v(1:p,l)
! ORDER THE SINGULAR VALUE.
590 IF (l == mm) GO TO 600
! ...EXIT
IF (s(l) >= s(l+1)) GO TO 600
t = s(l)
s(l) = s(l+1)
s(l+1) = t
IF (wantv .AND. l < p) CALL dswap1(p, v(1:,l), v(1:,l+1))
IF (wantu .AND. l < n) CALL dswap1(n, u(1:,l), u(1:,l+1))
l = l + 1
GO TO 590
600 iter = 0
m = m - 1
610 GO TO 360
620 RETURN
END SUBROUTINE dsvdc
END MODULE SVD

@ -1,189 +0,0 @@
MODULE INTFCMOD
IMPLICIT NONE
PUBLIC :: INITLEVELS, TRANSF, COVG
CONTAINS
SUBROUTINE INITLEVELS(T,HT,N,NU,Nv)
USE TBRMOD
USE SIZEMOD
IMPLICIT NONE
C INTEGER, PARAMETER:: NMAX = 101, RDIM = 10201
C DIMENSION ULEVELS(1),Vlevels(1),T(1),HT(1),TG(1),XG(1),HH(101)
REAL*8, DIMENSION(:), intent(in) :: T
REAL*8, DIMENSION(:), intent(out) :: HT
C INTEGER, intent(in) :: NG
REAL*8 :: UMIN,UMAX,VMIN,VMAX, HU,HV
integer :: N, I, NU, NV
C REAL*8, DIMENSION(NMAX) :: HH
C COMMON/TBR/HH
C IF (NG.GT.501) THEN
C PRINT *,'Vector defining transformation of data > 501, stop'
C STOP
C END IF
IF(N.ge.NMAX) then
print *,'The number of wavelength points >',NMAX-1, ' stop'
stop
end if
IF(N.lt.2) then
print *,'The number of wavelength points < 2, stop'
stop
end if
HT(1)=0.5d0*(T(2)-T(1))
HT(N)=0.5d0*(T(N)-T(N-1))
HH(1)=-100.0d0
HH(N)=-100.0d0
DO I=2,N-1
HT(I)=0.5d0*(T(I+1)-T(I-1))
HH(I)=-100.0d0
c10 CONTINUE
enddo
IF(NU.gt.NMAX) then
print *,'The number of maxima >',NMAX,' stop'
stop
end if
IF(NV.gt.NMAX) then
print *,'The number of minima >',NMAX,' stop'
stop
end if
IF(NU.LT.1) Then
print *,'The number of maxima < 1, stop'
stop
end if
IF(NV.LT.1) Then
print *,'The number of minima < 1, stop'
stop
end if
RETURN
END SUBROUTINE INITLEVELS
SUBROUTINE TRANSF(N,T,A,TIMEV,VALUE,DER)
C
C N number of data points
C TIMEV vector of time points
C A a vector of values of a function G(TIME)
C T independent time point
C VALUE is a value of a function at T, i.e. VALUE=G(T).
c DER=G'(t)
C
USE SIZEMOD
IMPLICIT NONE
REAL*8, intent(inout):: VALUE, DER,T
C INTEGER, PARAMETER :: RDIM = 10201
REAL*8, DIMENSION(:), intent(in) :: A,TIMEV
integer, intent(in) :: N
REAL*8:: T1
integer :: I
IF (T.LT.TIMEV(1)) then
der=(A(2)-A(1))/(TIMEV(2)-TIMEV(1))
T1=T-TIMEV(1)
VALUE=A(1)+T1*DER
return
end if
IF (T.GT.TIMEV(N)) then
der = (A(N)-A(N-1))/(TIMEV(N)-TIMEV(N-1))
T1 = T-TIMEV(N)
VALUE=A(N)+T1*DER
return
end if
DO I=2,N
IF (T.LT.TIMEV(I)) GO TO 10
ENDDO
10 I=I-1
T1=T-TIMEV(I)
DER=(A(I+1)-A(I))/(TIMEV(i+1)-TIMEV(I))
VALUE=A(I)+T1*DER
RETURN
END SUBROUTINE TRANSF
REAL*8 FUNCTION SPLE(N,T,A,TIMEV)
C
C N number of data points
C TIME vector of time points
C A a vector of values of a function G(TIME)
C T independent time point
C SPLE is a value of a function at T, i.e. SPLE=G(T).
C
USE SIZEMOD
IMPLICIT NONE
INTEGER, INTENT(IN):: N
REAL*8, INTENT(IN) :: T
REAL*8, DIMENSION(:), INTENT(IN) :: A,TIMEV
REAL*8 :: T1
INTEGER :: I
SPLE=-9.9d0
IF (T.LT.TIMEV(1) .OR. T.GT.TIMEV(N)) RETURN
DO I=2,N
IF (T.LT.TIMEV(I)) GO TO 10
ENDDO
10 I=I-1
T1=T-TIMEV(I)
SPLE=A(I)+T1*(A(I+1)-A(I))/(TIMEV(i+1)-TIMEV(I))
RETURN
END FUNCTION SPLE
SUBROUTINE COVG(XL0,XL2,XL4,COV1,COV2,COV3,COV,T,N)
C
C Covariance function and its four derivatives for a vector T of length N
C is assumed in a vector COV; COV(1,...,N,1)=r(T), COV(1,...,N, 2)=r'(T), etc.
C The vector COV should be of the shape N x 5.
C
C COVG Returns:
C XL0,XL2,XL4 - spectral moments.
C
C Covariance matrices COV1=r'(T-T), COV2=r''(T-T) and COV3=r'''(T-T)
C Dimension of COV1, COV2 should be atleast N*N.
C
USE SIZEMOD
! IMPLICIT NONE
C INTEGER, PARAMETER:: NMAX = 101, RDIM = 10201
REAL*8, PARAMETER:: ZERO = 0.0d0
REAL*8, intent(inout) :: XL0,XL2,XL4
REAL*8, DIMENSION(N,5), intent(in) :: COV
REAL*8, DIMENSION(N), intent(in) :: T
REAL*8, DIMENSION(RDIM), intent(inout) :: COV1,COV2,COV3
INTEGER, intent(in) :: N
integer :: I, J, II
REAL*8 :: TT, T0
C
C COV(Y(T),Y(0)) = COV(:,1)
C DERIVATIVE COV(Y(T),Y(0)) = COV(:,2)
C 2-DERIVATIVE COV(Y(T),Y(0)) = COV(:,3)
C 3-DERIVATIVE COV(Y(T),Y(0)) = COV(:,4)
C 4-DERIVATIVE COV(Y(T),Y(0)) = COV(:,5)
XL0 = COV(1,1)
XL2 = -COV(1,3)
XL4 = COV(1,5)
! XL0 = SPLE(NT, ZERO, COV(:,1), T)
! XL2 = -SPLE(NT, ZERO, COV(:,3), T)
! XL4 = SPLE(NT, ZERO, COV(:,5), T)
II=0
DO I=1,N
DO J=1,N
II = II+1
T0 = T(J)-T(I)
TT = ABS(T0)
COV1(II) = SPLE(N, TT, COV(:,2), T)
COV2(II) = SPLE(N, TT, COV(:,3), T)
COV3(II) = SPLE(N, TT, COV(:,4), T)
IF (T0.LT.0.0d0) then
COV1(II)=-COV1(II)
COV3(II)=-COV3(II)
endif
enddo
enddo
RETURN
END SUBROUTINE COVG
END module intfcmod

File diff suppressed because it is too large Load Diff

@ -1,20 +0,0 @@
"""
builds mvn.pyd
"""
import os
import sys
from wafo.f2py_tools import f2py_call_str
def compile_all():
f2py_call = f2py_call_str()
print '=' * 75
print 'compiling mvn'
print '=' * 75
os.system(f2py_call + ' mvn.pyf mvndst.f -c ')
if __name__ == '__main__':
compile_all()

@ -1,39 +0,0 @@
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module mvn ! in
interface ! in :mvn
subroutine mvnun(d,n,lower,upper,means,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f
integer intent(hide) :: d=shape(means,0)
integer intent(hide) :: n=shape(means,1)
double precision dimension(d) :: lower
double precision dimension(d) :: upper
double precision dimension(d,n) :: means
double precision dimension(d,d) :: covar
integer intent(optional) :: maxpts=d*1000
double precision intent(optional) :: abseps=1e-6
double precision intent(optional) :: releps=1e-6
double precision intent(out) :: value
integer intent(out) :: inform
end subroutine mvnun
subroutine mvndst(n,lower,upper,infin,correl,maxpts,abseps,releps,error,value,inform) ! in :mvn:mvndst.f
integer intent(hide) :: n=len(lower)
double precision dimension(n) :: lower
double precision dimension(n) :: upper
integer dimension(n) :: infin
double precision dimension(n*(n-1)/2) :: correl
integer intent(optional) :: maxpts=2000
double precision intent(optional) :: abseps=1e-6
double precision intent(optional) :: releps=1e-6
double precision intent(out) :: error
double precision intent(out) :: value
integer intent(out) :: inform
integer :: ivls
common /dkblck/ ivls
end subroutine mvndst
end interface
end python module mvn
! This file was auto-generated with f2py (version:2.39.235_1752).
! See http://cens.ioc.ee/projects/f2py2e/

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save