@@ -5,12 +5,13 @@ Introduction to sdss_access
5
5
===============================
6
6
7
7
SDSS Access provides a convenient way of navigating local and remote filesystem paths from the Science Archive Server (SAS).
8
- `sdss_access ` uses the SDSS Tree product for all path look-ups.
8
+ `` sdss_access ` ` uses the SDSS Tree product for all path look-ups.
9
9
10
10
Path Generation
11
11
---------------
12
12
13
- You can generate full paths to local files easily with `Path.full `::
13
+ You can generate full paths to local files easily with `Path.full <.BasePath.full> `.
14
+ ::
14
15
15
16
# import the path
16
17
from sdss_access import SDSSPath
@@ -21,7 +22,8 @@ You can generate full paths to local files easily with `Path.full`::
21
22
'/Users/Brian/Work/sdss/sas/mangawork/manga/spectro/redux/v2_3_1/8485/stack/manga-8485-1902-LOGCUBE.fits.gz'
22
23
23
24
Note that this only generates a path. The file may not actually exist locally. If you want to generate a URL path to
24
- the file on the SAS at Utah, you can use `Path.url `::
25
+ the file on the SAS at Utah, you can use `Path.url <.BasePath.url> `.
26
+ ::
25
27
26
28
# generate a http path to the file
27
29
path.url('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG')
@@ -39,26 +41,28 @@ be an empty string.
39
41
Path Names
40
42
----------
41
43
42
- The syntax for all paths defined in `sdss_access `, for most methods, is ``(name, **kwargs) ``. Each path is defined by
44
+ The syntax for all paths defined in `` sdss_access ` `, for most methods, is ``(name, **kwargs) ``. Each path is defined by
43
45
a **name ** and several **keyword arguments **, indicated in the template filepath by **{keyword_name} **. For example,
44
46
the path to a MaNGA data cube has **name ** ``mangacube `` and path keywords, **plate **, **drpver **, **ifu **, and **wave **,
45
47
defined in the path ``$MANGA_SPECTRO_REDUX/{drpver}/{plate}/stack/manga-{plate}-{ifu}-{wave}CUBE.fits.gz ``. All paths
46
- are defined inside the SDSS `tree ` product, within a `[PATHS] ` section in the environment configuration files, e.g. `data/sdsswork.cfg `
47
- or `data/dr15.cfg `. Within `sdss_access `, all paths are available as a dictionary, ``path.templates ``::
48
+ are defined inside the SDSS `` tree ` ` product, within a `[PATHS] ` section in the environment configuration files, e.g. `data/sdsswork.cfg `
49
+ or `data/dr15.cfg `. Within `` sdss_access ` `, all paths are available as a dictionary, ``path.templates ``::
48
50
49
51
from sdss_access.path import SDSSPath
50
52
path = SDSSPath()
51
53
52
54
# show the dictionary of available paths
53
55
path.templates
54
56
55
- To look up what path names are available, you can use ``path.lookup_names ``::
57
+ To look up what path names are available, you can use `Path.lookup_names <.BasePath.lookup_names> `.
58
+ ::
56
59
57
60
# look up the available path names
58
61
path.lookup_names()
59
62
['BOSSLyaDR_cat', ..., 'mangacube', ..., 'xdqso_index']
60
63
61
- To look up what keywords are needed for a given path, you can use ``path.lookup_keys ``::
64
+ To look up what keywords are needed for a given path, you can use `Path.lookup_keys <.BasePath.lookup_keys> `.
65
+ ::
62
66
63
67
# look up the keyword arguments needed to define a MaNGA cube path
64
68
path.lookup_keys('mangacube')
@@ -80,24 +84,83 @@ the ``remote`` keyword argument
80
84
path.exists('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG', remote=True)
81
85
True
82
86
87
+ Environment Paths
88
+ -----------------
89
+
90
+ By default, when instantiating a new `.Path `, it will automatically load the ``tree `` environment from any currently loaded
91
+ module file, identified with any `TREE_VER ` environment variable. Otherwise it loads the ``sdsswork `` environment, and all
92
+ paths relevant to that environment.
93
+ ::
94
+
95
+ >>> # load the default environment / paths
96
+ >>> from sdss_access.path import Path
97
+ >>> path = Path()
98
+ >>> path
99
+ <Path(release="sdsswork", public=False, n_paths=358)
100
+
101
+ To access paths from a different environment, you can change environments by passing in the ``release `` keyword argument. The
102
+ ``release `` acts as an indicator for both a valid data release, e.g. "DR15", and a valid environment configuration,
103
+ e.g. "sdsswork".
104
+ ::
105
+
106
+ >>> # load the sdss5 environment and paths
107
+ >>> from sdss_access.path import Path
108
+ >>> path = Path(release='sdss5')
109
+ >>> path
110
+ <Path(release="sdss5", public=False, n_paths=97)
111
+
112
+ >>> # switch to the environment for public data release DR15
113
+ >>> path = Path(release='DR15')
114
+ >>> path
115
+ <Path(release="dr15", public=True, n_paths=325)
116
+
117
+ When reloading a new ``tree `` environment configuration, ``sdss_access `` automatically updates the Python session
118
+ ``os.environ `` with the relevant environment variables for the given release/configuration. You can preserve your original
119
+ ``os.environ `` by setting the ``preserve_envvars `` keyword to True. This will preserve your original environment in its
120
+ entirety.
121
+ ::
122
+
123
+ >>> # load the sdss5 environment but preserve your original os.environ
124
+ >>> path = Path(release='sdss5', preserve_envvars=True)
125
+
126
+ Alternatively, you can preserve a subset of enviroment variables from your original ``os.environ `` by passing in a list of
127
+ environment variables.
128
+ ::
129
+
130
+ >>> # preserve only a single environment variable
131
+ >>> path = Path(release='sdss5', preserve_envvars=['ROBOSTRATEGY_DATA'])
132
+
133
+ If you wish to permanently preserve your locally set environment variables, you can set the ``preserve_envvars `` parameter to
134
+ ``true `` in a custom tree YAML configuration file located at ``~/.config/sdss/sdss_access.yml ``. For example
135
+ ::
136
+
137
+ preserve_envvars: true
138
+
139
+ Alternatively, you can permanently set a subset of environment variables to preserve by defining a list.
140
+ ::
141
+
142
+ preserve_envvars:
143
+ - ROBOSTRATEGY_DATA
144
+ - ALLWISE_DIR
145
+
83
146
Downloading Files
84
147
-----------------
85
148
86
- You can download files from the SAS and place them in your local SAS. `sdss_access ` expects a local SAS filesystem
149
+ You can download files from the SAS and place them in your local SAS. `` sdss_access ` ` expects a local SAS filesystem
87
150
that mimics the real SAS at Utah. If you do not already have a `SAS_BASE_DIR ` set, one will be defined in your
88
- home directory, as a new `sas ` directory.
151
+ home directory, as a new `` sas ` ` directory.
89
152
90
153
sdss_access has four classes designed to facilitate access to SAS data.
91
154
92
- - **Access ** - class that automatically decides between `RsyncAccess ` and `CurlAccess ` based on the operating system.
155
+ - **Access ** - class that automatically decides between `. RsyncAccess ` and `. CurlAccess ` based on the operating system.
93
156
- **HttpAccess ** - uses the `urllib ` package to download data using a direct http request
94
157
- **RsyncAccess ** - uses `rsync ` to download data. Available for Linux and MacOS.
95
158
- **CurlAccess ** - uses `curl ` to download data. This is the only available method for use on Windows machines.
96
159
97
- Note that all remote access classes, after instantiation, must call the `` remote() `` method before adding paths to ensure
98
- successful downloading of data.
160
+ Note that all remote access classes, after instantiation, must call the `Access. remote <.BaseAccess.remote> ` method before
161
+ adding paths to ensure successful downloading of data.
99
162
100
- Using the `HttpAccess ` class.
163
+ Using the `. HttpAccess ` class.
101
164
102
165
::
103
166
@@ -110,7 +173,7 @@ Using the `HttpAccess` class.
110
173
# get the file
111
174
http_access.get('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG')
112
175
113
- Using the `RsyncAccess ` class. `RsyncAccess ` is generally much faster then `HttpAccess ` as it spreads multiple
176
+ Using the `. RsyncAccess ` class. `. RsyncAccess ` is generally much faster then `. HttpAccess ` as it spreads multiple
114
177
file downloads across multiple continuous rsync download streams.
115
178
116
179
::
@@ -132,25 +195,25 @@ file downloads across multiple continuous rsync download streams.
132
195
# start the download(s)
133
196
rsync.commit()
134
197
135
- The default mode of `RsyncAccess ` is for collaboration access. You can also access data from publicly available
136
- SDSS data releases, by specifying the `public ` and `release ` keyword arguments on init.
198
+ The default mode of `. RsyncAccess ` is for collaboration access. You can also access data from publicly available
199
+ SDSS data releases, by specifying the `` public `` and `` release ` ` keyword arguments on init.
137
200
138
201
::
139
202
140
203
# setup rsync access to download public data from DR14
141
204
rsync = RsyncAccess(public=True, release='dr14')
142
205
143
- Using the `CurlAccess ` class. `CurlAccess ` behaves exactly the same way as `RsyncAccess `. After importing and
144
- instantiating a `CurlAccess ` object, all methods and behavior are the same as in the `RsyncAccess ` class.
206
+ Using the `. CurlAccess ` class. `. CurlAccess ` behaves exactly the same way as `. RsyncAccess `. After importing and
207
+ instantiating a `. CurlAccess ` object, all methods and behavior are the same as in the `. RsyncAccess ` class.
145
208
::
146
209
147
210
# import the curl class
148
211
from sdss_access import CurlAccess
149
212
curl = CurlAccess()
150
213
151
- Using the `Access ` class. Depending on your operating system, `posix ` or not, Access will either create itself using
152
- `RsyncAccess ` or `CurlAccess `, and behave as either object. Via `Acccess `, Windows machines will always use `CurlAccess `,
153
- while Linux or Macs will automatically utilize `RsyncAccess `.
214
+ Using the `. Access ` class. Depending on your operating system, `` posix ` ` or not, Access will either create itself using
215
+ `. RsyncAccess ` or `. CurlAccess `, and behave as either object. Via `. Acccess `, Windows machines will always use `. CurlAccess `,
216
+ while Linux or Macs will automatically utilize `. RsyncAccess `.
154
217
::
155
218
156
219
# import the access class
@@ -168,8 +231,8 @@ while Linux or Macs will automatically utilize `RsyncAccess`.
168
231
access.set_stream()
169
232
access.commit()
170
233
171
- In all all cases, successful `sdss_access ` downloads will return a code of 0. Any other number indicates that a problem
172
- occurred. If no verbose message is displayed, you may need to check the `sdss_access_XX.log ` and `sdss_access_XX.err `
234
+ In all all cases, successful `` sdss_access ` ` downloads will return a code of 0. Any other number indicates that a problem
235
+ occurred. If no verbose message is displayed, you may need to check the `` sdss_access_XX.log `` and `` sdss_access_XX.err ` `
173
236
files within the temporary directory.
174
237
175
238
Accessing Public Data Products
@@ -262,17 +325,17 @@ instantiation.
262
325
path.full('mangapreimg', designid=8405, designgrp='D0084XX', mangaid='1-42007')
263
326
'/Users/Brian/Work/sdss/data/manga/mangapreim/trunk/data/D0084XX/8405/preimage-1-42007_irg.jpg'
264
327
265
- You can also set the ``force_modules `` parameter in your custom config file, ``~/.config/sdss_access /sdss_access.yml `` to
328
+ You can also set the ``force_modules `` parameter in your custom config file, ``~/.config/sdss /sdss_access.yml `` to
266
329
set it once permanently.
267
330
268
331
.. _sdss-access-windows :
269
332
270
333
Notes for Windows Users
271
334
-----------------------
272
335
273
- `sdss_access ` downloads files into a directory defined by the `SAS_BASE_DIR ` enviroment variable. If this path points
336
+ `` sdss_access ` ` downloads files into a directory defined by the `SAS_BASE_DIR ` enviroment variable. If this path points
274
337
to another drive other than the C drive, make sure that the new drive and paths have full write permissions available
275
- to `curl `. `CurlAccess ` may not work properly until correct permissions are set up in your folder system.
338
+ to `curl `. `. CurlAccess ` may not work properly until correct permissions are set up in your folder system.
276
339
277
340
.. _sdss-access-api :
278
341
@@ -281,29 +344,29 @@ Reference/API
281
344
282
345
.. rubric :: Class
283
346
284
- .. autosummary :: sdss_access.path.Path
285
- .. autosummary :: sdss_access.Access
286
- .. autosummary :: sdss_access.HttpAccess
287
- .. autosummary :: sdss_access.RsyncAccess
288
- .. autosummary :: sdss_access.CurlAccess
347
+ .. autosummary :: sdss_access.path.path. Path
348
+ .. autosummary :: sdss_access.sync.access. Access
349
+ .. autosummary :: sdss_access.sync.http. HttpAccess
350
+ .. autosummary :: sdss_access.sync.rsync. RsyncAccess
351
+ .. autosummary :: sdss_access.sync.curl. CurlAccess
289
352
290
353
.. rubric :: Methods
291
354
292
355
.. autosummary ::
293
356
294
- sdss_access.SDSSPath .full
295
- sdss_access.SDSSPath .url
296
- sdss_access.SDSSPath .lookup_names
297
- sdss_access.SDSSPath .lookup_keys
298
- sdss_access.SDSSPath .extract
299
- sdss_access.SDSSPath .location
300
- sdss_access.SDSSPath .name
301
- sdss_access.SDSSPath .dir
302
- sdss_access.SDSSPath .any
303
- sdss_access.SDSSPath .expand
304
- sdss_access.SDSSPath .random
305
- sdss_access.SDSSPath .one
306
- sdss_access.Access .remote
307
- sdss_access.Access .add
308
- sdss_access.Access .set_stream
309
- sdss_access.Access .commit
357
+ sdss_access.path.path.BasePath .full
358
+ sdss_access.path.path.BasePath .url
359
+ sdss_access.path.path.BasePath .lookup_names
360
+ sdss_access.path.path.BasePath .lookup_keys
361
+ sdss_access.path.path.BasePath .extract
362
+ sdss_access.path.path.BasePath .location
363
+ sdss_access.path.path.BasePath .name
364
+ sdss_access.path.path.BasePath .dir
365
+ sdss_access.path.path.BasePath .any
366
+ sdss_access.path.path.BasePath .expand
367
+ sdss_access.path.path.BasePath .random
368
+ sdss_access.path.path.BasePath .one
369
+ sdss_access.sync.baseaccess.BaseAccess .remote
370
+ sdss_access.sync.baseaccess.BaseAccess .add
371
+ sdss_access.sync.baseaccess.BaseAccess .set_stream
372
+ sdss_access.sync.baseaccess.BaseAccess .commit
0 commit comments