Skip to content

Commit 49f2a20

Browse files
Merge branch 'master' into script_convert_indexed_output_to_array
# Conflicts: # scripts/__init__.py
2 parents be1d5e4 + a51b310 commit 49f2a20

11 files changed

Lines changed: 105 additions & 36 deletions

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ script:
3939
- flake8 parcels
4040
- flake8 tests
4141
- flake8 examples
42-
- flake8 scripts
43-
- python scripts/pull_data.py
42+
- python parcels/scripts/pull_data.py
4443
- py.test -v -s tests/
4544
- py.test -v -s examples/

examples/parcels_tutorial.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
},
5151
"outputs": [],
5252
"source": [
53-
"from parcels import FieldSet, ParticleSet, Variable, JITParticle, AdvectionRK4\n",
54-
"from scripts import plotTrajectoriesFile\n",
53+
"from parcels import FieldSet, ParticleSet, Variable, JITParticle, AdvectionRK4, plotTrajectoriesFile\n",
5554
"import numpy as np\n",
5655
"import math\n",
5756
"from datetime import timedelta\n",

examples/tutorial_delaystart.ipynb

Lines changed: 97 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {},
5+
"metadata": {
6+
"deletable": true,
7+
"editable": true
8+
},
69
"source": [
710
"## Tutorial on how to 'delay' the start of particle advection"
811
]
912
},
1013
{
1114
"cell_type": "markdown",
12-
"metadata": {},
15+
"metadata": {
16+
"deletable": true,
17+
"editable": true
18+
},
1319
"source": [
1420
"In many applications, it is needed to 'delay' the start of particle advection. For example because particles need to be released at different times throughout an experiment.\n",
1521
"\n",
@@ -22,52 +28,70 @@
2228
"cell_type": "code",
2329
"execution_count": 1,
2430
"metadata": {
25-
"collapsed": true
31+
"collapsed": true,
32+
"deletable": true,
33+
"editable": true
2634
},
2735
"outputs": [],
2836
"source": [
29-
"from parcels import FieldSet, ParticleSet, JITParticle\n",
37+
"from parcels import FieldSet, ParticleSet, JITParticle, plotTrajectoriesFile, convert_IndexedOutputToArray\n",
3038
"from parcels import AdvectionRK4\n",
3139
"import numpy as np\n",
32-
"from datetime import timedelta as delta\n",
33-
"from scripts import *"
40+
"from datetime import timedelta as delta"
3441
]
3542
},
3643
{
3744
"cell_type": "markdown",
38-
"metadata": {},
45+
"metadata": {
46+
"deletable": true,
47+
"editable": true
48+
},
3949
"source": [
4050
"Now import a `FieldSet` (from the Peninsula example, in this case)"
4151
]
4252
},
4353
{
4454
"cell_type": "code",
4555
"execution_count": 2,
46-
"metadata": {},
56+
"metadata": {
57+
"collapsed": true,
58+
"deletable": true,
59+
"editable": true
60+
},
4761
"outputs": [],
4862
"source": [
4963
"fieldset = FieldSet.from_nemo('Peninsula_data/peninsula', allow_time_extrapolation = True)"
5064
]
5165
},
5266
{
5367
"cell_type": "markdown",
54-
"metadata": {},
68+
"metadata": {
69+
"deletable": true,
70+
"editable": true
71+
},
5572
"source": [
5673
"Define an empty `ParticleSet`"
5774
]
5875
},
5976
{
6077
"cell_type": "code",
6178
"execution_count": 3,
62-
"metadata": {},
79+
"metadata": {
80+
"collapsed": true,
81+
"deletable": true,
82+
"editable": true
83+
},
6384
"outputs": [],
6485
"source": [
6586
"pset = ParticleSet(fieldset=fieldset, lon=[], lat=[], pclass=JITParticle)"
6687
]
6788
},
6889
{
6990
"cell_type": "markdown",
70-
"metadata": {},
91+
"metadata": {
92+
"deletable": true,
93+
"editable": true
94+
},
7195
"source": [
7296
"And now also define some other variables"
7397
]
@@ -76,7 +100,9 @@
76100
"cell_type": "code",
77101
"execution_count": 4,
78102
"metadata": {
79-
"collapsed": true
103+
"collapsed": true,
104+
"deletable": true,
105+
"editable": true
80106
},
81107
"outputs": [],
82108
"source": [
@@ -87,7 +113,10 @@
87113
},
88114
{
89115
"cell_type": "markdown",
90-
"metadata": {},
116+
"metadata": {
117+
"deletable": true,
118+
"editable": true
119+
},
91120
"source": [
92121
"We use the same start locations as in `examples/example_peninsula.py`"
93122
]
@@ -96,7 +125,9 @@
96125
"cell_type": "code",
97126
"execution_count": 5,
98127
"metadata": {
99-
"collapsed": true
128+
"collapsed": true,
129+
"deletable": true,
130+
"editable": true
100131
},
101132
"outputs": [],
102133
"source": [
@@ -107,7 +138,10 @@
107138
},
108139
{
109140
"cell_type": "markdown",
110-
"metadata": {},
141+
"metadata": {
142+
"deletable": true,
143+
"editable": true
144+
},
111145
"source": [
112146
"Now we define an output file. Note that, since not each particle will have the same number of timesteps outputted (because some will be released later than others), we need to run with `type=\"indexed\"`. See also H3.5 at http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/aphs03.html"
113147
]
@@ -116,7 +150,9 @@
116150
"cell_type": "code",
117151
"execution_count": 6,
118152
"metadata": {
119-
"collapsed": true
153+
"collapsed": true,
154+
"deletable": true,
155+
"editable": true
120156
},
121157
"outputs": [],
122158
"source": [
@@ -125,15 +161,22 @@
125161
},
126162
{
127163
"cell_type": "markdown",
128-
"metadata": {},
164+
"metadata": {
165+
"deletable": true,
166+
"editable": true
167+
},
129168
"source": [
130169
"Now we run the combination of `pset.add()` and `pset.execute()` calls inside a `for`-loop."
131170
]
132171
},
133172
{
134173
"cell_type": "code",
135174
"execution_count": 7,
136-
"metadata": {},
175+
"metadata": {
176+
"collapsed": false,
177+
"deletable": true,
178+
"editable": true
179+
},
137180
"outputs": [
138181
{
139182
"name": "stderr",
@@ -156,15 +199,22 @@
156199
},
157200
{
158201
"cell_type": "markdown",
159-
"metadata": {},
202+
"metadata": {
203+
"deletable": true,
204+
"editable": true
205+
},
160206
"source": [
161207
"And then we run the particles for the rest of the time until `endtime`"
162208
]
163209
},
164210
{
165211
"cell_type": "code",
166212
"execution_count": 8,
167-
"metadata": {},
213+
"metadata": {
214+
"collapsed": true,
215+
"deletable": true,
216+
"editable": true
217+
},
168218
"outputs": [],
169219
"source": [
170220
"pset.execute(AdvectionRK4, runtime=endtime-npart*delaytime,\n",
@@ -174,15 +224,22 @@
174224
},
175225
{
176226
"cell_type": "markdown",
177-
"metadata": {},
227+
"metadata": {
228+
"deletable": true,
229+
"editable": true
230+
},
178231
"source": [
179232
"And then finally, we can show a movie of the particles. Note that one particle appears every frame for the first ten frames."
180233
]
181234
},
182235
{
183236
"cell_type": "code",
184237
"execution_count": 9,
185-
"metadata": {},
238+
"metadata": {
239+
"collapsed": false,
240+
"deletable": true,
241+
"editable": true
242+
},
186243
"outputs": [
187244
{
188245
"data": {
@@ -438,15 +495,22 @@
438495
},
439496
{
440497
"cell_type": "markdown",
441-
"metadata": {},
498+
"metadata": {
499+
"deletable": true,
500+
"editable": true
501+
},
442502
"source": [
443503
"Now, the ``type=indexed`` file is not too easy to work with in further analysis, so Parcels provides a function ``convert_IndexedOutputToArray`` to reformat an Indexed particle file to an Array one"
444504
]
445505
},
446506
{
447507
"cell_type": "code",
448508
"execution_count": 10,
449-
"metadata": {},
509+
"metadata": {
510+
"collapsed": false,
511+
"deletable": true,
512+
"editable": true
513+
},
450514
"outputs": [
451515
{
452516
"name": "stderr",
@@ -462,15 +526,22 @@
462526
},
463527
{
464528
"cell_type": "markdown",
465-
"metadata": {},
529+
"metadata": {
530+
"deletable": true,
531+
"editable": true
532+
},
466533
"source": [
467534
"And we can also make a movie of this file. Note that generating movies for Array-style particle files tends to be much faster than for Indexed-style files, particularly when the files become very big."
468535
]
469536
},
470537
{
471538
"cell_type": "code",
472539
"execution_count": 11,
473-
"metadata": {},
540+
"metadata": {
541+
"collapsed": false,
542+
"deletable": true,
543+
"editable": true
544+
},
474545
"outputs": [
475546
{
476547
"data": {

examples/tutorial_periodic_boundaries.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
},
5353
"outputs": [],
5454
"source": [
55-
"from parcels import FieldSet, ParticleSet, JITParticle\n",
55+
"from parcels import FieldSet, ParticleSet, JITParticle, plotTrajectoriesFile\n",
5656
"from parcels import AdvectionRK4\n",
5757
"from datetime import timedelta as delta\n",
58-
"from scripts import plotTrajectoriesFile\n",
5958
"import math"
6059
]
6160
},

parcels/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
import parcels.rng as random # noqa
77
from parcels.particlefile import * # noqa
88
from parcels.kernels import * # noqa
9+
from parcels.scripts import * # noqa

parcels/scripts/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .plotParticles import plotTrajectoriesFile # NOQA get flake8 to ignore unused import.
2+
from .convert_IndexedOutputToArray import * # NOQA
File renamed without changes.

scripts/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)