@@ -198,21 +198,27 @@ def get_w7x_data(Nt_coils=48, Nt_ma=10, ppp=2):
198198
199199
200200@SimsoptRequires (requests is not None , "You need to install the requests library to use this function. Run 'pip install requests'" )
201- def get_QUASR_data (ID , return_style = 'default ' ):
201+ def get_QUASR_data (ID , return_style = 'quasr-style ' ):
202202 """
203- Download a configuration from the QUASAR database.
203+ Download a configuration from the QUASR database.
204204
205205 Args:
206206 ID: the ID of the configuration to download. The database is navigatable at https://quasr.flatironinstitute.org/
207207 Alternatively, you can download the latest full set of devices from https://zenodo.org/doi/10.5281/zenodo.10050655
208208
209- return_style: 'default' or 'json'. If 'default', the function will return the curves, currents and magnetic axis
210- like the other configurations in the zoo.
211- If 'json' the function will return the full set of coils, magnetic axis and a number of surfaces
212- parametrized in Boozer coordinates.
209+ return_style: 'simsopt-style' or 'quasr-style'. '.
210+ simsopt-style: [coils_1fp, surface], similar to get_ncsx_data(), gives the curves and currenst for one field period,
211+ which you can copy and rotate using simsopt methods (allows finer control over degrees-of-freedom).
212+ NOTE: this does not return the magnetic axis.
213+ quasr-style: [coils_all, surfaces], returns all coils and all surfaces in the object.
214+
215+ returns: depending on return_style:
216+ simsopt-style: [list of simsopt.geo.Coil objects, list of simsopt.field.Current objects]
217+ quasr-style: [list of simsopt.geo.SurfaceXYZTensorFourier objects, list of simsopt.field.COIL objects]
213218 """
214219
215- assert return_style in ['default' , 'json' ]
220+ if return_style not in ['simsopt-style' , 'quasr-style' ]:
221+ raise ValueError (f"invalid return_style: { return_style } , must be either simsopt-style or quasr-style" )
216222
217223 id_str = f"{ ID :07d} "
218224 # string to 7 digits
@@ -221,18 +227,20 @@ def get_QUASR_data(ID, return_style='default'):
221227 with requests .get (url ) as r :
222228 if r .status_code == 200 :
223229 print (f"Configuration with ID { ID :07} downloaded successfully" )
224- surfaces , ma , coils = json .loads (r .content , cls = GSONDecoder )
230+ surfaces , coils = json .loads (r .content , cls = GSONDecoder )
225231 else :
226- raise ValueError (f"Configuration ID { ID :07d} does not exist . Status code: { r .status_code } " )
232+ raise ValueError (f"Download of ID { ID :07d} failed . Status code: { r .status_code } \n Check if the confituration exists " )
227233
228- if return_style == 'default ' :
229- nfp = ma .nfp
230- nc_per_hp = len (coils ) // nfp // (1 + ma .stellsym )
234+ if return_style == 'simsopt-style ' :
235+ nfp = surfaces [ 0 ] .nfp
236+ nc_per_hp = len (coils ) // nfp // (1 + surfaces [ 0 ] .stellsym )
231237 coils = coils [:nc_per_hp ]
232238
233239 curves = [coil .curve for coil in coils ]
234240 currents = [coil .current for coil in coils ]
235- return curves , currents , ma
241+ return curves , currents
242+ elif return_style == 'quasr-style' :
243+ return surfaces , coils
244+ else :
245+ raise ValueError #should not be reached as we check before download to avoid clobbering the database.
236246
237- elif return_style == 'json' :
238- return coils , ma , surfaces
0 commit comments