utils package

Submodules

utils.dscreader module

Wrapper class and helper methods for the Timepix DSC files. This file is primarily written by Dr. Tom Whyntie, and has been modified by Will Furnell for just getting values from the DSC files (removing non relevant parts and includes).

utils.dscreader.DSC_NAME_SN_STRING = '"Name+SN" ("Name and serial number"):'

Convenience values for dataset processing. Obtained from: https://raw.githubusercontent.com/CERNatschool/daqmap-zip-processor/master/cernatschool/datavals.py

class utils.dscreader.DscFile(dscfilename)[source]

Bases: object

A wrapper class for the Pixelman DSC files.

getAcqMode()[source]
getAcqTime()[source]
getBiasLVDS()[source]
getBiasVoltage()[source]
getBuffAnalogA()[source]
getBuffAnalogB()[source]
getChipId()[source]
getDACs()[source]
getDataFilename()[source]
getDisc()[source]
getDscFilename()[source]
getFBK()[source]
getFirmwareVersion()[source]
getFrameHeight()[source]
getFrameWidth()[source]
getGND()[source]
getHist()[source]
getHwTimerMode()[source]
getIKrum()[source]
getInterface()[source]
getMpxClock()[source]
getMpxType()[source]
getNameAndSerialNumber()[source]
getPixelmanVersion()[source]
getPolarity()[source]
getPreamp()[source]
getRefLVDS()[source]
getStartTime()[source]
getStartTimeS()[source]
getTHL()[source]
getTHLCoarse()[source]
getTHS()[source]
getTpxClock()[source]
getVcas()[source]
processDscFile()[source]

Process the detector settings file (.dsc).

utils.dscreader.TPX_CLOCK_VALS = {0: 10.0, 1: 20.0, 2: 40.0, 3: 80.0}

Handler methods for various parts of the Timepix datafiles.

utils.dscreader.getPixelmanTimeString(st)[source]

Get the timestring in the Pixelman (custom) format.

utils.dscreader.isChipIdValid(chipid)[source]

Does the chip ID conform to the UVV-XYYYY format?

utils.filetester module

utils.filetester.dsc_files_present(file_names)[source]

Check if the corresponding detector settings files exist.

Parameters:file_names – The list of file names to be checked
Returns:True if they do exist, false if they do not
utils.filetester.get_format_from_var(f)[source]

Used to get the file format from a file that is currently in memory

Parameters:f – The file in memory to be checked
Returns:The file type value of the file

utils.upload module

utils.upload.flatten(directory_to_flatten)[source]

Used to flatten (remove all directories) a folder structure

Parameters:directory_to_flatten – Directory that needs to be flattened
Returns:Nothing if successful, False if failed
utils.upload.get_file_list(path)[source]

Used to get a list of files in a directory

Parameters:path – The path of the directory to get a list of files from
Returns:The list of files
utils.upload.upload_handler(file, form, user)[source]

The actual function used to upload files to the system. Used to check if the ZIP file and its contents is valid. If so, extracts it to the OUTPUT_FOLDER/UPLOAD_ID and puts information that the user provides into the database about the upload, and about the frames. Also extracts information from DSC files and puts this into the database using dscreader.py

Parameters:
  • file – The (hopefully) ZIP file that the user has uploaded
  • form – The UploadForm object provided by the view
  • user – The current User that has uploaded the file
Returns:

False and error code if failed, True and None if upload was successful

utils.usertests module

utils.usertests.has_institution_edit_permission(user)[source]

Checks whether a user can add institutions to the system or not

Parameters:user – The current user of the system to be checked
Returns:True if they can edit institutions, False if they cannot
utils.usertests.has_langton_email(user)[source]

Checks whether the user has a Langton email address

Parameters:user – The current user of the system to be checked
Returns:True or False
utils.usertests.has_not_verified(user)[source]

Checks whether the user has not verified their account yet

Parameters:user – The current user of the system to be checked
Returns:True if they have not verified, False if they have
utils.usertests.has_upload_permission(user)[source]

Checks whether a user has permission to upload files to the system

Parameters:user – The current user of the system to be checked
Returns:True if they are allowed, False if they are not
utils.usertests.has_verified(user)[source]

Checks if the current user has verified their account yet or not

Parameters:user – The current user of the system to be checked
Returns:True if they have verified, False if they have not
utils.usertests.is_admin(user)[source]

Check whether a user is admin or not :param user: The current user of the system to be checked :return: True if they are an admin, false if not