Skip to content

Database RamanDB() and vino integration#2

Open
dccote wants to merge 22 commits intomainfrom
vinoTesting
Open

Database RamanDB() and vino integration#2
dccote wants to merge 22 commits intomainfrom
vinoTesting

Conversation

@dccote
Copy link
Contributor

@dccote dccote commented Mar 29, 2022

Context

I created a database RamanDB() that can be used to obtain the spectra with some constraints (color, 'raw' or 'corrected'). You must have the dcclab module (pip install dcclab).
The actual database is on cafeine and can be accessed remotely without problems (SSH tunnel, automatic, using account dcclab). It makes use of the module keyring that will store the password in the system keychain (install with pip install keyring) and sshtunnel (install with pip install sshtunnel). If the password is not found, it will tell you how to add it with a simple command.

Usage

# In the same directory as ramandb.py
from ramandb import RamanDB
db = RamanDB()
spectra, labels = db.getSpectraWithId(dataType='raw', color='white')
# spectra is a numpy array, labels are the column labels
correctedSpectra = db.subtractFluorescence(spectra, polynomialDegree=10)

With the basic functions of RamanDB(), it is possible to reconstruct the database from scratch if needed.

Caveats

The database has been patially integrated in vino.py, but it is not complete.
Many checks will be added to RamanDB and the MySQL database schema to maintain the coherence of the data.

dccote added 14 commits March 25, 2022 21:43
I figured out the data format for `vinoPCA.Data`
Working, but we need to flush the 'T' wines for the rest of the code to work. Bad code.
Not using files anymore.
wavelength range is now part of the calss properties
I have now defined spectrumId, which corresponds to the string "wineId-sampleId".
We can now store the results of calculations in the spectra table and keep track of the algorithm used.  Currently, raw or 'fluorescence-corrected'
…, not 100).

Fixed it at great lengths, but now red wine test passes.
@dccote dccote self-assigned this Mar 29, 2022
@dccote dccote changed the title vino testing Database RamanDB() and vino integration Mar 29, 2022
Copy link
Contributor

@mirequem mirequem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai eu un problème en essayant testDatabase, ce n'était pas possible d'accéder au serveur avec la commande keyring set mysql-cafeine2.crulrg.ulaval.ca dcclab. J'ai dû ajouter manuellement cafeine2-ssh et mysql-cafeine2.crulrg.ulaval.ca dans mon "trousseau d'accès" (keychain).

@dccote
Copy link
Contributor Author

dccote commented Mar 30, 2022

J'ai eu un problème en essayant testDatabase, ce n'était pas possible d'accéder au serveur avec la commande keyring set mysql-cafeine2.crulrg.ulaval.ca dcclab. J'ai dû ajouter manuellement cafeine2-ssh et mysql-cafeine2.crulrg.ulaval.ca dans mon "trousseau d'accès" (keychain).

Je pense que j'ai trouvé: je me rappelle que ca se plaignait d'un "backend" absent. Peut-etre qu'il faut configurer directement pour dire que c'est macos. Par la ligne de commande, ca ne fonctionnait pas. Essaie ca:

keyring -b keyring.backends.OS_X.Keyring set "some-label" "some-tag"

@dccote dccote requested a review from mirequem March 30, 2022 01:23
Copy link

@AntoineRousseau97 AntoineRousseau97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai eu les mêmes problèmes que mireille. Toutefois, en suivant ses démarches, ca ne fonctionne toujours pas pour moi... J'ai toujours le message suivant:
Skipped: Now in setUp
Set the password in the system password manager on the command line with:
python -m keyring set mysql-cafeine2.crulrg.ulaval.ca dcclab
You should update PyDCCLab with pip install dcclab to get the latest version.

Comment on lines +32 to +40
uniqueLabelsInOrder = sorted(set(self.labels))
possibleColorsInOrder = range(len(uniqueLabelsInOrder))
colors = {}
for identifier, color in zip(uniqueLabelsInOrder, possibleColorsInOrder):
colors[identifier] = color*5

colormap = []
for identifier in self.labels:
colormap.append(colors[identifier])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai l'impression que quelque chose ne fonctionne pas avec la fonction colormap. Le nombre de couleur sur nos graphiques dépasse le nombre de bouteilles. La fonction set() permettrait de simplement garder les 19 valeurs différentes mais les labels sont 0000-0001 etc.. Donc j'ai l'impression qu'on crée N couleurs différentes... J'ai testé une autre méthode et le couleurs semblaient fonctionner

Suggested change
uniqueLabelsInOrder = sorted(set(self.labels))
possibleColorsInOrder = range(len(uniqueLabelsInOrder))
colors = {}
for identifier, color in zip(uniqueLabelsInOrder, possibleColorsInOrder):
colors[identifier] = color*5
colormap = []
for identifier in self.labels:
colormap.append(colors[identifier])
splitId = []
for i in range(0, len(self.labels)):
splitId.append(self.labels[i].split("-"))
colormap = list(map(int, list(zip(*splitId))[0]))
return np.array(colormap)

@shooshoo1997
Copy link
Collaborator

J'ai obtenue le même message que Antoine. Cependant en utilisant python -m keyring set mysql-cafeine2.crulrg.ulaval.ca dcclab et en entrant le mot de passe manuellement, mon problème était réglé. Le code roule pour moi mais il reste cependant une erreur (qui ne change pas les résultats) :

.2022-03-31 20:55:42,049| ERROR | Password is required for key /Users/Shooshoo/.ssh/id_rsa
Forwarding 127.0.0.1:52846 to dcclab@cafeine2.crulrg.ulaval.ca:3306 through SSH tunnel
You should update PyDCCLab with pip install dcclab to get the latest version.

Je ne sais pas où fournir ma clé et je ne sais pas non plus pourquoi est-ce que j'ai besoin de la donner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants