@@ -5,12 +5,13 @@ Introduction to sdss_access
55===============================
66
77SDSS 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.
99
1010Path Generation
1111---------------
1212
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+ ::
1415
1516 # import the path
1617 from sdss_access import SDSSPath
@@ -21,7 +22,8 @@ You can generate full paths to local files easily with `Path.full`::
2122 '/Users/Brian/Work/sdss/sas/mangawork/manga/spectro/redux/v2_3_1/8485/stack/manga-8485-1902-LOGCUBE.fits.gz'
2223
2324Note 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+ ::
2527
2628 # generate a http path to the file
2729 path.url('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG')
@@ -39,26 +41,28 @@ be an empty string.
3941Path Names
4042----------
4143
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
4345a **name ** and several **keyword arguments **, indicated in the template filepath by **{keyword_name} **. For example,
4446the path to a MaNGA data cube has **name ** ``mangacube `` and path keywords, **plate **, **drpver **, **ifu **, and **wave **,
4547defined 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 ``::
4850
4951 from sdss_access.path import SDSSPath
5052 path = SDSSPath()
5153
5254 # show the dictionary of available paths
5355 path.templates
5456
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+ ::
5659
5760 # look up the available path names
5861 path.lookup_names()
5962 ['BOSSLyaDR_cat', ..., 'mangacube', ..., 'xdqso_index']
6063
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+ ::
6266
6367 # look up the keyword arguments needed to define a MaNGA cube path
6468 path.lookup_keys('mangacube')
@@ -80,24 +84,83 @@ the ``remote`` keyword argument
8084 path.exists('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG', remote=True)
8185 True
8286
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+
83146Downloading Files
84147-----------------
85148
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
87150that 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.
89152
90153sdss_access has four classes designed to facilitate access to SAS data.
91154
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.
93156- **HttpAccess ** - uses the `urllib ` package to download data using a direct http request
94157- **RsyncAccess ** - uses `rsync ` to download data. Available for Linux and MacOS.
95158- **CurlAccess ** - uses `curl ` to download data. This is the only available method for use on Windows machines.
96159
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.
99162
100- Using the `HttpAccess ` class.
163+ Using the `. HttpAccess ` class.
101164
102165::
103166
@@ -110,7 +173,7 @@ Using the `HttpAccess` class.
110173 # get the file
111174 http_access.get('mangacube', drpver='v2_3_1', plate='8485', ifu='1901', wave='LOG')
112175
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
114177file downloads across multiple continuous rsync download streams.
115178
116179::
@@ -132,25 +195,25 @@ file downloads across multiple continuous rsync download streams.
132195 # start the download(s)
133196 rsync.commit()
134197
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.
137200
138201::
139202
140203 # setup rsync access to download public data from DR14
141204 rsync = RsyncAccess(public=True, release='dr14')
142205
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.
145208::
146209
147210 # import the curl class
148211 from sdss_access import CurlAccess
149212 curl = CurlAccess()
150213
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 `.
154217::
155218
156219 # import the access class
@@ -168,8 +231,8 @@ while Linux or Macs will automatically utilize `RsyncAccess`.
168231 access.set_stream()
169232 access.commit()
170233
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 ` `
173236files within the temporary directory.
174237
175238Accessing Public Data Products
@@ -262,17 +325,17 @@ instantiation.
262325 path.full('mangapreimg', designid=8405, designgrp='D0084XX', mangaid='1-42007')
263326 '/Users/Brian/Work/sdss/data/manga/mangapreim/trunk/data/D0084XX/8405/preimage-1-42007_irg.jpg'
264327
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
266329set it once permanently.
267330
268331.. _sdss-access-windows :
269332
270333Notes for Windows Users
271334-----------------------
272335
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
274337to 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.
276339
277340.. _sdss-access-api :
278341
@@ -281,29 +344,29 @@ Reference/API
281344
282345.. rubric :: Class
283346
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
289352
290353.. rubric :: Methods
291354
292355.. autosummary ::
293356
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